Created
August 17, 2012 03:20
-
-
Save myokoym/3375641 to your computer and use it in GitHub Desktop.
Problem036
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
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