Maximum triangle path sum: Difference between revisions

m
→‎{{header|Ruby}}: Compatibility with Ruby < 1.9
m (→‎{{header|Java}}: small changes)
m (→‎{{header|Ruby}}: Compatibility with Ruby < 1.9)
Line 659:
until ar.size == 1 do
maxes = ar.pop.each_cons(2).map(&:max)
ar[-1]= ar[-1].zip(maxes).flat_mapmap{|r1,r2| r1 + r2}.flatten
end
puts ar # => 1320</lang>
Anonymous user