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.
Just checking the available ?? 0 would be enough instead of divsion to NaN. Recipe will always have some vlaue I guess
Hey Les - Wow I really appreciate the detailed response! I love simplicity and intentionality. I love the transition of the loop to the functinal, but especially love the every version. So clean / clear. Alright now I need to go solve 1000x problems so I can start to understand your solutions!
You get better at anything by practicing it. So make a game out of it where you apply it every chance you get. Your approaches in the beginning will look and feel awkward, but you'll get better with practice. Eventually you will arrive at a point where functional makes as much sense as the imperative loop-based implementations -- usually with a lot less code because the loops are hidden behind the higher-ordered functions. Once you are used to functional approaches you are likely to find that bugs are more evident because the loop mechanics aren't in the way (that and you'll learn to avoid side effects, mutability, etc... you'll solve problems with functional composition, keeping your lambda's/arrow-functions short and sweet.)
At its root, functional list processing is map, filter and reduce. But there are lots of variations of these operations that have names that can make your functional code speak more to its intent than its imperative equivalent. So for example - you could implement a test to see if all of the integers in an array is even like this:
With reduce:
...but that's less expressive than using the 'every' method on array (not to mention the reduce and the naive loop implementation are less efficient too):
Why are they less efficient? Because we could've stopped the moment we hit an odd item because we know that the end result would be false. The every method on Array does this early out without processing the rest of the items only you don't have to think about it.
The approach I used here could've been much different. See if you can solve and improve upon it, purely functionally.
Good luck!
I am not an expert in regex, but if I understand
[^#] means not a #
? means match the previous token [^#] zero or one time
literally match the character
So altogether, find a character that is NOT # followed by a #. Then if found, the author just replaces that with ''.
wow. this is the coolest recursive I have ever seen
nvm. got it. that's super super smart.
This comment is hidden because it contains spoiler information about the solution
can you explain the || here?
could you explain the checkUnique function?
this is insane. the way of finding the region is amazing
love how the column was extracted
This is some black magic here. After melting my brain trying to understand this for 10 minutes, it is such a cool solution. I love the functional approach. Any advice on how to get better in functional proramming / to find a functional solution like this?
This comment is hidden because it contains spoiler information about the solution
this is nuts