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.
Shame I can't jump to your solution to vote it up, not only it's really clever it's much faster than top voted and mine.
To be exact most "clever" solution is 9 (!) times slower than yours.
Hate the way Codewars promotes writing functions in slow wank style as "Clever Best Practices" :/
Result without benchmark setup is rather meaningless.
Not sure if using Stream is a good idea. I did some benchmark and exec time up ~70% comparing to Enum.filter. So I would rather vote Clever :)
Agree on 3ky, quite easy. I'll get to choppa, thanx :)
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!
This solution is 30 times slower than mine :) Indeed to understand recursion you have to understand recursion first ;)
After submiting I benchmarked this solution against top 10 solutions and this one is the killer. Although my other solution is nifty :)
Indeed. This code is too complex and slow. It may seems "clever", but its definitely not BP
So slow ... I came up with two solutions for this prob, one-string-but-slow solution and fast one. This solution is 2 times slower than my slow :)
Clever solution. I wish I knew product method before.
Elegant solution! Even kind of has a philosophical ring to it :)
Nice one. I've got mine from same string of Test source code :)
This comment is hidden because it contains spoiler information about the solution
The most interesting solution. Mine is also not using eval, but quite simple and easy to read. @JoshBrodieNZ your solution is universal, man, you could use it for half of katas with minor changes ;)
Loading more items...