Skip to content

Instantly share code, notes, and snippets.

@bew

bew/loop.cr Secret

Created March 26, 2017 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bew/de1741e55c06580db6a535d53e9b7a6b to your computer and use it in GitHub Desktop.
Save bew/de1741e55c06580db6a535d53e9b7a6b to your computer and use it in GitHub Desktop.
Loop.cr
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