Skip to content

Instantly share code, notes, and snippets.

@myokoym
Created August 17, 2012 03:20
Show Gist options
  • Save myokoym/3375641 to your computer and use it in GitHub Desktop.
Save myokoym/3375641 to your computer and use it in GitHub Desktop.
Problem036
class String
def palindrome?
self == self.split(//).reverse.join
end
end
ans = []
1.upto(1000000) do |n|
if [n.to_s, n.to_s(2)].all? {|v| v.palindrome? }
p "#{n} : #{n.to_s(2)}"
ans << n
end
end
p ans.inject(:+)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment