euler/ruby/euler004.rb

10 lines
202 B
Ruby
Raw Normal View History

require_relative 'euler'
2014-04-25 23:59:14 +00:00
def products_of_three_digits
2018-02-21 21:00:08 +00:00
(100..999).to_a.combination(2).map { |p| p.inject(:*) }
2014-04-25 23:59:14 +00:00
end
def solution
products_of_three_digits.select { |x| Euler.palindrome?(x) }.max
2014-04-25 23:59:14 +00:00
end