Skip to content

Instantly share code, notes, and snippets.

@cored
Created April 29, 2013 21:24
Show Gist options
  • Save cored/5484918 to your computer and use it in GitHub Desktop.
Save cored/5484918 to your computer and use it in GitHub Desktop.
def is_palindrome?(str)
str.reverse == str
end
count = 0
File.open('seed.txt') do |file|
file.each_line do |line|
start, finish = line.split(/\s/, 2).map(&:to_i)
(start..finish).each { |x| count += 1 if is_palindrome?(x.to_s) }
end
end
puts count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment