-
-
Save bew/de1741e55c06580db6a535d53e9b7a6b to your computer and use it in GitHub Desktop.
Loop.cr
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
struct Int | |
def palindrome? | |
self.to_s == self.to_s.reverse | |
end | |
end | |
nums = Array(Int32).new.tap do |yielder| | |
(100..999).each do |i| | |
(i..999).each do |j| | |
yielder << i * j | |
end | |
end | |
end.each | |
puts nums.select(&.palindrome?).max |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment