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.
Basically, this one has it all and I've never said that before. It's waaay better than mine. The only thing: if line 2 was "var result = [];" you wouldn't need the ternary on line 5, you'd just concat every time.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Yours has MORE RegExp and is LESS readable, what are you talking about. And if the scoring was going to be changed, you'd have to change your patterns in two places instead of one.
Is it just me or is this written to loop though every single node of the array before recognizing duplicates? You should be able to break much earlier than that if you've touched a duplicate inside a loop. And if you sort and join, doesn't that loop through an array as well?
If the recipe is blank, you return Infinity. You don't provide for breaking the loop as soon as you know you can produce 0 of the recipe. There are two cases where that can happen.
I don't think "if (key in supplies)" is really what you want to go for here. If supplies.key == 0 it makes you do that math, push zero to your array, and continue the array instead of just returning 0. And why an array of numbers? You just need the smallest number you've found yet and return it at the end.
I have to credit this solution for one thing, using an operator I hadn't seen before. I just learned a lot of new operators.
The loop's first if is unnecessary. You don't need an array, you just need a single integer, maximum cakes, that decreases to the smallest integer on each loop. If your Math.floor results in a zero, you need to return 0 then and there.
YES to those comments. This exercise is terrible!
Don't! There are other protocols and limitless subdomains that a URL can contain.
How would they avoid state changes while keeping the code really readable, which is a virtue of their solution? Chaining replaces strains that. Maybe a second method that takes the string and an array of strings to remove from the main string?
The list of TLDs is much longer than this and it grows over time. This is unreliable.
You wrote this for a bad test. There are plenty of URLs with subdomains that aren't 'www' and there are other protocols too.
Loading more items...