Created
May 24, 2012 19:23
-
-
Save yanks/2783691 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_palindrome?(test) | |
str = test.to_s | |
split = str.length/2 | |
front = str[0..split-1] | |
back = str[str.length-split, str.length] | |
front == back.reverse! | |
end | |
i = 999 | |
result = 0 | |
while i > 100 | |
(100..999).each do |j| | |
test = i*j | |
if is_palindrome?(test) && result < test then | |
puts "RESULT: #{i} #{j}" | |
result = test | |
end | |
end | |
i-=1 | |
end | |
puts result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment