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.
Javascript doesn't throw array index out of bounds exceptions. It simply returns undefined.
Since undefined is not equal to any possible value of opposite[dir], this will always evaluate false on the first run of the loop.
it doesnt; it pushes on the first run not pop
what types can't be anticipated?
@Calgiles3 In line 4 array with directions is returned or empty array if no direction is found (instead of null). Hope it helps!
Just in case someone else runs into this confusion: minimizing i takes precedence over minimizing j. This seemed consistent to me.
How 2 totally different test cases with totally different approaches to solve can contradict each other?
7
. You walk through7
's. You end up at7
. You haven't changed your altitude even once - result is0
.0
. At some point you have to climb up to1
. At some point you have to climb down from1
, so you can end up at0
. The result is2
.Ask the opposite question then: why is this
0
?If you can't construct an example that gives a result of
0
, you can't claim it should be0
.For the same reason maybe? You can't get from top left corner to bottom right corner without changing altitude.
It's the
difference
, not their individualvalue
;-)That you can't use
eval
orFunction
in your code either.Server side JS should be like this indeed. You should get away from your comfort zone in Java and learn all the other wonderful things in life ;-)
Could you define this "JS way of coding"?
I think you should read the description again. For
209917
there is only one possible answer:[29917, O, 1]
.I"m very sorry, the tests cases are consistent through all languages (it is the same algorithm everywhere) and - see the top of the page - lots of guys passed the kata.
When a kata has a lot of translations it's a good idea to state which one you're having troubles with.
Loading more items...