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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
high
function so no need to make it accessible everywhere.high
with variables inside it.)Hope that helps :)
Not technically correct I think?
Afaict would give a false positive for
a1 = ["ab, "]
a2 = ["ab", "cd"]
I'm guessing it would be buggy if value+amount overflows, would require a very long (> max int - 256) string of "+"s though...
TBH I'm not very consistent with when I add an assert or not.
But asserting is not only for a "Just in case my earlier code was faulty" (your whole program would crash so you better make sure not to make earlier code faulty), it can also be useful for reading code. Because you won't have to worry about some things that you otherwise might worry about.
For example in this case when someone reads the interpret method one doesn't have to worry about different operations/commands since the assertion error explicitly states there shouldn't be any (the message string is probably poorly chosen).
@dinglemouse
So turns out I didn't have to escape it :X
Thanks for the info :)
I'm not 100% sure but I think that replaceAll doesn't do a lot since afaik a (non-escaped) dot in regex means pretty much any character.
As Unnamed said, it is indeed to indicate a certain condition that is not possible. Perhaps an 'assert false' would've been a bit cleaner or perhaps I could've left it out all together. I always find it difficult to decide.
Thanks :)
Changed it to "Java"
@donaldsebleung thanks for your feedback! :)
It's my first time doing a translation/kumite in general so I appreciate any feedback.
I totally forgot to add random test cases, sorry. I've added them now.
I'm not sure how you mean the "Test Cases" section has to be open?
Does that mean when I publish it the tab has to be selected? I can't remember which tab was selected when I published.
EDIT: I think I understand what you meant and if I'm right it shows the correct output now.
As for the "JavaScript" test cases, I changed them to "Java>Script" ;)
I'm not sure if it's a "good" joke though, so if you prefer "Java" I'll change it to that :)
If you find 2 heads and one body it could be unclear whether it's 3 or only 2 dead though...
Yea thanks for the explanation, I've been trying to sovle it for hours thinking there should be some easy math way but just couldn't find it.
Clever to iterate for j from right to left, but you should break that loop as soon as it finds one.
Could someone explain why this works but returning inside the if(cursor.mark !== undefined) fails?
And also why it fails when you put var res inside the function scope?
Because I can't see for the life of me how that changes any functionality.
(My first try was very similar as this except with immediate return etc. and I couldn't(/can't) figure out at all why it doesn't work.)
Loading more items...