2014-11-20 22:20:39 +00:00
|
|
|
require_relative 'euler'
|
2014-04-25 23:59:14 +00:00
|
|
|
|
2014-11-20 22:20:39 +00:00
|
|
|
def triangle_enumerator
|
|
|
|
Enumerator.new do |y|
|
|
|
|
sum = 1
|
|
|
|
next_num = 2
|
|
|
|
loop do
|
|
|
|
y << sum
|
|
|
|
sum += next_num
|
|
|
|
next_num += 1
|
|
|
|
end
|
2014-04-25 23:59:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-11-20 22:20:39 +00:00
|
|
|
def solution
|
|
|
|
triangle_enumerator.take_while { |x| x.divisors.count <= 500 }.last
|
2014-04-25 23:59:14 +00:00
|
|
|
end
|