Skip to content

Instantly share code, notes, and snippets.

@cored

cored/test.rb Secret

Created April 29, 2013 19:26
Show Gist options
  • Save cored/4b911a94fbbf6c1e7781 to your computer and use it in GitHub Desktop.
Save cored/4b911a94fbbf6c1e7781 to your computer and use it in GitHub Desktop.
class Fixnum
def is_palindrome?
self.to_s.reverse == self.to_s
end
end
count = 0
File.readlines('seed.txt').each do |line|
start, finish = line.split(/\s/)
count = (start.to_i..finish.to_i).to_a.map(&:to_i).reduce(0) do |s, n|
s += n if n.is_palindrome?
end
end
puts count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment