Created
February 3, 2016 15:40
-
-
Save mame-n/94135f706e6506c663ab to your computer and use it in GitHub Desktop.
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 P55 | |
def main | |
(1..9999).select { |i| i.lychrel? }.size | |
end | |
end | |
class Integer | |
def reverse | |
self.to_s.reverse.to_i | |
end | |
def palindrome? | |
self == self.reverse | |
end | |
def lychrel? | |
_self = self | |
(1..50).all? do |i| | |
!(_self += _self.reverse).palindrome? | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment