3 ms·
Couple minutes in ruby without using the knowledge of the binomial theorem or coefficients. def p(row) [1,Range.new(0, row.length - 2).map {|l|
by mbernstein 15y ago
Couple minutes in ruby without using the knowledge of the binomial theorem or coefficients.
def p(row)
[1,Range.new(0, row.length - 2).map {|l|
row[l] + row[l+1]
}, 1].flatten
end
a = [1]
while true
a = p(a)
puts a.inspect
end
edit: fixed formatting, sorry :(