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.
The best one. Same algorithm as mine.
this is very fast and efficient in my benchmark. I love it!
This comment is hidden because it contains spoiler information about the solution
Nice one, I think this will give the best performance.
Computationally, yes.
I prefer spending computer cycles over brain cycles though, to a certain extent of course.
You cast the result to string anyway, isn't using modulo (6 times) more expensive in this case?
There's a couple of nice things about this solution:
It's tidy, each
if
statement has one line and the result at the end.The if statements are mutually exclusive, so no need for
if else
.The default is just set.
The modulo
%
operator was used for finding the last digit(s), so no casting to string was necessary