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.
Your code is very slow, as you can read. Try to speed up him using dynamic programming ( basics of it )
n - you go north
whats the opposite of north? south
s - you go south
so go north 5 times, south 5 times
+5, then -5. youre back at starting position now
You have to find two different elements of the given array arr that add to x.
"Isn't it suppose to be false?"
No. This set of direction moves back and forth. The case You assume should have "n" in last element. Then end wil be in different point than start. Last argument which is "s" moves You back to start point so condition in this case is true.
I still don't get it. The requirement said it's must be back to starting point, then why isValidWalk(['n','s','n','s','n','s','n','s','n','s'] return true?
First point is n, last point is s. Isn't it suppose to be false?
You need to count how many squares / blocks you are going to walk. Therefore, the matrix must have exactly 10 values.
The second point is that when you go, you need to go back, so if you walk in one direction, you need to go back the same number of times.
Please read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution This is a
Question
, not a kataSuggestion
. It's also explained there what you're doing wrong.