One case has expected solution:
[D,D,R,R,R,R,R,D,D,L,D,L,U,L,L,D,L,D], but there is actually a shorter path:
[D,D,R,R,R,R,R,D,D,L, L, L,L,D,L,D] which avoids a detour round a small cul-de-sac.
The configuration for the last two test cases (12x12) has two equally good paths, since there is an open square at 2,10 3,10 2,11 3,11; so paths:
...D,R,R, R,U, U,U...,
...D,R,R, U,R, U,U...
both work.
I have editted the test cases to fix the size and remove the ambiguities. I hope the changes seem OK to you,
In the test case "Should work with complex path (7x7 map)", I got this failure:
Should work with complex path (7x7 map)
Should return the right moves
expected: Just [D,D,R,R,R,R,R,D,D,L,D,L,U,L,L,D,L,D]
but got: Just [D,D,R,R,R,R,R,D,D,L,L,L,L,D,L,D]
D,L,U has been replaced with L.
It seems to be the valid answer as well.
Why this works? Can we do it with x amount of arguments?
Ok, thank you 😂
You colud at least remove console.log ...
Last one fixed. I've done the following modify:
The
@
is the added one.Thank you for your feedback.
All what you said make sense. The first two are fixed now.
The map was
I've changed it into
And your answer is correct.
I'll modify the map, wait
Three problems in the test cases
A 7x7 test cases is actually 7 x 6
One case has expected solution:
[D,D,R,R,R,R,R,D,D,L,D,L,U,L,L,D,L,D], but there is actually a shorter path:
[D,D,R,R,R,R,R,D,D,L, L, L,L,D,L,D] which avoids a detour round a small cul-de-sac.
The configuration for the last two test cases (12x12) has two equally good paths, since there is an open square at 2,10 3,10 2,11 3,11; so paths:
...D,R,R, R,U, U,U...,
...D,R,R, U,R, U,U...
both work.
I have editted the test cases to fix the size and remove the ambiguities. I hope the changes seem OK to you,
Mark
In the test case "Should work with complex path (7x7 map)", I got this failure:
D,L,U
has been replaced withL
.It seems to be the valid answer as well.