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.
So it's sorted alphabetically first, when the sum is equal. It's somewhat cheesy but it works.
Didn't even think of a graph. Clever and efficient solution.
I used a bunch of folds that would essentially reorder the word, given a few simple rules.
I just tested and it does result in
[West, West]
. Note that becausefoldr
is lazy, allcollapse
function applications will be delayed until the start element is reached.Kind of like this:
Since it's folding from the right side (it's
foldr
) it goes backwards so it's reducing correctly.Very clever in my opinion. A good example of how to use
foldr
properly.