euler/ruby/euler040.rb

17 lines
381 B
Ruby
Raw Normal View History

2014-11-17 19:52:46 +00:00
def champernowe_constant_up_to(n)
(1..n).to_a.join('')
end
def solution
champernowe = champernowe_constant_up_to(1000000)
digits = []
digits << champernowe[0]
digits << champernowe[9]
digits << champernowe[99]
digits << champernowe[999]
digits << champernowe[9999]
digits << champernowe[99999]
digits << champernowe[999999]
digits.map(&:to_i).inject(:*)
end