- Path following algorithm in ASCII Map
- Find the position of character '@'
- Follow the path, stop when character 'x' is reached
Write a piece of code that takes ASCII map as an input and outputs the letters and the path that algorithm travelled.
- Input:
- ASCII map
- Output:
- Collected letters
- Path as characters
@---A---+
|
x-B-+ C
| |
+---+
Expected result:
- Letters
ACB
- Path as characters
@---A---+|C|+---+|+-B-x
@
| C----+
A | |
+---B--+
| x
| |
+---D--+
Expected result:
- Letters
ABCD
- Path as characters
@|A+---B--+|+----C|-||+---D--+|x
@---+
B
K-----|--A
| | |
| +--E |
| | |
+--E--Ex C
| |
+--F--+
Expected result:
- Letters
BEEFCAKE
- Path as characters
@---+B||E--+|E|+--F--+|C|||A--|-----K|||+--E--Ex