Skip to content

Instantly share code, notes, and snippets.

@yanks
Created May 24, 2012 19:23
Show Gist options
  • Save yanks/2783691 to your computer and use it in GitHub Desktop.
Save yanks/2783691 to your computer and use it in GitHub Desktop.
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