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.
Interesting question! Let's test:
JS Benchmark for several floor function alternatives
Results:
Math.floor
is about the same speed as other numeric methods for flooring a number, and all are far faster than you'll ever have to worry about.Conclusion: Use Math.floor for readability, but these kinds of micro-optimisations really do not matter lol.
Is it faster to use '~~' than 'floor' or is it the same?
Точно, багнет. Нужно в isNotLeaf на !==undefined проверять.
Там есть тест, где на конце (2 0) и 0 нужно исправить на 1. Этот код работает, т.к. на существование проверяется левое число (т.е. 2), но если бы комбинация была наоборот: (0 2), то код бы багнул?? "if (0)" - вернёт false же. Или я что-то не увидел?