21
2
You are trapped in this 5x5 labyrinth - each room is labelled from 1 to 25 and the exit is in room 1.
You are given as input the room you are currently in. Your task is to output the shortest sequence of moves (north, east, south, west) needed to reach room 1.
Moves can be output in any format you wish (list, string, array...) as long as you use the characters n,w,e,s
.
Here are all the test cases:
1 => empty string/list
2 => w
3 => ww
4 => swwnw
5 => wswwnw
6 => seenwnw
7 => nw
8 => wnw
9 => wwnw
10 => swwnwnw
11 => eenwnw
12 => enwnw
13 => nwnw
14 => wnwnw
15 => wwnwnw
16 => enenwnw
17 => nenwnw
18 => wnenwnw
19 => nwnwnw
20 => wnwnwnw
21 => nenenwnw
22 => enwnenwnw
23 => nwnenwnw
24 => wnwnenwnw
25 => nwnwnwnw
Shortest answer in bytes wins!
Do we have to work with differents labyrinths ? If yes, how do we get the walls as input ? – The random guy – 2019-09-17T06:55:27.807
3How flexible is the room labeling / input? Can we 0-index instead of 1-index? Can we take the room number as a character (thinking, as in base 36)? – Chas Brown – 2019-09-17T07:04:16.557
2@Therandomguy no, you need to handle this specific labyrinth. – Arnaud – 2019-09-17T07:12:57.163
hence, the [tag:kolmogorov-complexity] tag – Unrelated String – 2019-09-17T07:14:30.833
6Since it is possible, I think all possible cases should be included in the test cases. – Jonathan Frech – 2019-09-17T07:27:28.083
This is what I've come up with, but haven't rigorously verified – Unrelated String – 2019-09-17T07:29:38.300
1@UnrelatedString This question take 1 input, and output different path based on its input. I believe this requirement does not fit the [tag:kolmogorov-complexity] tag. – tsh – 2019-09-17T08:06:00.220
@JonathanFrech Shaggy done! – Arnaud – 2019-09-17T10:11:16.473
Could you address @ChasBrown's questions, please? – Shaggy – 2019-09-17T10:12:40.407
@Shaggy the room number has to be an integer and starts at 1 - no 0-indexing. – Arnaud – 2019-09-17T10:19:30.900
2
Someone needs to provide an answer in Labyrinth.
– Draco18s no longer trusts SE – 2019-09-18T15:09:44.987I can't see the image. – S.S. Anne – 2019-09-19T15:43:00.433