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.
Also note that this optimisation depends on
O(1)
access from right to left ( or just plainO(1)
random access ).The Haskell version uses cons-lists, so no cheap right-to-left access. Other non-esoteric languages probably all have it though.
LC requires exporting
snoc
ascons
for this to work.There is the eternal tension between performance and simplicity, readability and maintainability, in the light of the ranking of the kata.
I tried once, for a too short while, to achieve what you did, but didn't think it through enough and gave up too quickly; I never got there. Kudos for your solution.
But being disappointed in less performant but correct and readable solutions to a
7kyu
kata seems setting yourself up for a lot of disappointment. :P