I am bumming...
Category None
Because of Admin2006 , I missed the last day of the Da Vinci Quest that was running on Google. I realize that I had no chance of winning, but I was enjoying the little puzzles each day. I especially liked the Sudoku like puzzles that used graphics instead of numbers. So I was thinking, as a lot of the blog readers here are programmers, maybe I should start posting little programming puzzles every now, nothing fancy, but it would be fun to see what people come up with. As with any programming challenge, it's really the final result that counts, but sometimes with things like this people come up with amazing solutions. So here is the first of the Friday programming challenges...
Post your solutions and anything else you want as a comment
Because of Admin2006 , I missed the last day of the Da Vinci Quest that was running on Google. I realize that I had no chance of winning, but I was enjoying the little puzzles each day. I especially liked the Sudoku like puzzles that used graphics instead of numbers. So I was thinking, as a lot of the blog readers here are programmers, maybe I should start posting little programming puzzles every now, nothing fancy, but it would be fun to see what people come up with. As with any programming challenge, it's really the final result that counts, but sometimes with things like this people come up with amazing solutions. So here is the first of the Friday programming challenges...
Yesterday when driving my car, my mileage hit "49094", a number that reads the same forwards as backwards aka palindrome. Write the smallest (not necessarily the most efficient) amount of lotusscript code you can to return the number of palindromes my cars odometer will display before it gets to 51000 miles"
Post your solutions and anything else you want as a comment
Comments
Function c() As Integer
Dim i, j As Integer
i = 49094
While (i<51000)
If((Left(Cstr(i), 1) = Right(Cstr(i), 1)) & (Mid(Cstr(i), 2, 1) = Mid(Cstr(i), 4,1))) Then
j = j + 1
End If
i = i +1
Wend
c = j
End Function
Posted by Jason Thorpe At 10:22:52 AM On 05/12/2006 | - Website - |
Function c() As Integer
Dim i,j As Integer
i = 49094
j= 0
While (i<51000)
If((Left(Cstr(i), 1) = Right(Cstr(i), 1)) And (Mid(Cstr(i), 2, 1) = Mid(Cstr(i), 4,1))) Then
j= j + 1
End If
i = i +1
Wend
c = j
End Function
Posted by Jason Thorpe At 10:28:14 AM On 05/12/2006 | - Website - |
Function c() As Integer
Dim i,j As Integer
i = 49094
While (i<51000)
n = Cstr(i)
If Left(n, 1) = Right(n, 1) And Mid(n, 2, 1) = Mid(n, 4,1) Then
c= c + 1
End If
i = i +1
Wend
End Function
Posted by Jason Thorpe At 10:30:33 AM On 05/12/2006 | - Website - |
Function c() as Integer
c=20
End Function
Posted by Jason Thorpe At 10:48:48 AM On 05/12/2006 | - Website - |
Posted by Carl Tyler At 10:53:58 AM On 05/12/2006 | - Website - |
For x=49094 To 51000
s=Cstr(x)
res=Evaluate(|@For(n := @Length("| + s + |"); n >= 0; n := n - 1; temp2 := temp2 + @Middle("| + s + |";n;1)); temp2;|)
If (res(0)=s) Then
c=c+1
End If
Next
Messagebox("There are " + Cstr(c) + " palindromes")
Posted by David Bockes At 01:35:41 PM On 05/12/2006 | - Website - |