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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
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.
I think he definitely did it cause it was fancier lol. There's no need to do it
This comment is hidden because it contains spoiler information about the solution
foi isso que pensei tambem
The third generate function member is a lambda function. [] brackets for variables initialized outside lambda. mutable used here in order to be able modify the k variable.
"#{ VALUE } Chinese Yuan"
— is effectively equal toVALUE + " Chinese Yuan"
"%0.2f" % VALUE
— here%
is a method on String instances, it formats givenVALUE
using this string(in this case
0.2f
formats a number, result ofusd * 6.75
expression, with precision of two digits after the dot)This comment is hidden because it contains spoiler information about the solution
As a guess, I'd say 32 is the smallest power of 2 that is large enough for either of the answers.
Some people like to keep everything in powers of 2 (so your code would have s[128] instead) for "efficiency".
Someone more experimented may correct me or give more precision, but I understood that using bitwise operators was generally way more efficient. Though in a kata like this one it probably makes no significant difference. From now I generally try to use prioritarily them when they are appropriated.
Here rbegin() start from last it also called reverse beginning . Same for rend() also . Generally sort function return ascending order sort then descending is just reverse of it .
Thanks
I think, that in general, .at() is safer than [] in terms of exceptions throwing.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...