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.
Amazing !
Checking if the string length is odd is an obvious disqualifier that I didn't think to check for. Good call!
Your solution restate the kata more vividly. Here is my solution which shows that I had no idea about the epicenter of the issue.
This comment is hidden because it contains spoiler information about the solution
Bravo. I can sense that the performance here would be superb.
Note that you are off by 1, exactly, in one corner case.
Very similar in pilosophy to my first Solution.
I have two solutions, second is onliner recursive, first is iteration
Splice doesn't work the way you think it does. Your solution actually uses quadratically more memory allocations than this solution does. For that reason, splice is also the slowest array method in the language, making your solution quadratically slower.
Even in lower-level languages, arrays usually occupy a continuous chunk of memory addressed via offset, so there is no pointer to reassign, so splice can't be fast. Linked lists have that advantage, but also have distinct disadvantages (mainly slow data retrieval).
This comment is hidden because it contains spoiler information about the solution
Got it, I didn't know that the toFixed method rounds the number. Thank you so much!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Thanks @Grey, very informative writup. Now I'm looking deeper into tokenizing.
I appreciate tips on using comments better as well.
@cskyleryoung: The "runner up" wasn't always the runner-up. I don't think it's a stretch to say that both solutions helped each other gain points; ooflorent's solution and mine have a lot in common. The difference being, I've demonstrated how to use a tokenizer, which is generally good practice when writing a parser.
However, this language is really very simple and so many people took exception to my solution for being 'overkill' (just read the other comments). I expect it will soon lose the top spot. Which I am OK with, because I like the other solution as well (it is almost canonical). But when you start writing real world parsers, just know you can expect to write tokenizing/lexing code.
Please make sure your performance test will be accessible indefinitely, and next time you reference a different solution, please link to it. That way, your comments will stay intelligible in the future, even if the ranking changes.
As you have likely surmised it's because it takes a pass through to essentially remove all non parens first. One could simply ignore anything that isn't a paren.
Loading more items...