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
What does "%0${it.length}d" mean? Is it Regexp? Can't understand how it works.
haHa
Don't want to sound like a teacher... :) But sorting twice and specifying a Comparator with two criteria is not the same. In fact, sorting twice really does sort a list twice. If you have a large amount of elements, you will notice that. Having a sortedWith(...) specifies one comparator (no matter how many "thenBy" clauses you use - it will become one Comparator) sorts only once.
So, always use the one comparator approach. :-)
yeah nice catch! youre right, the third sortedByDescending is unnecesary.
but I belive sortedWith plus thenBy have same mechanism with sorting twice.
aside from that, folding or not, 96 or 'a' its same lah, not hiding any fact :D
cheers 🍻
You are unnecessarily sorting three(!) times - your last sortedByDescending is done even twice identically. But the main problem is that sorting by two criteria should never be done by sorting twice.
Folding with a start value of length is just disguising the otherwise pretty simple sum of the elements plus the length.
96 is a "magic constant" and which hides the fact you're actually subtracting 'a' and making it 1-based.
This is not to be considered a best practice at all... :-)