Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Result without benchmark setup is rather meaningless.
This algorithm actually gets exponentially slower as the number increases, so you can't really compare its speed in a 1:1 manner.
2.4.1 :061 > Benchmark.measure { pascalsTriangle(25) }
=> @real=0.000426109
2.4.1 :066 > Benchmark.measure { pascalsTriangle(125) }
=> @real=0.09114601
2.4.1 :062 > Benchmark.measure { pascalsTriangle(250) }
=> @real=3.03741528
2.4.1 :067 > Benchmark.measure { pascalsTriangle(500) }
=> @real=21.5128502
Took me a while looking through the Array docs to find
product
, I was trying hacky ways withpermutation
before that.This code is better than my own though!
Elegant solution! Even kind of has a philosophical ring to it :)
Thank you!