Your challenge, should you choose to accept it, is to take as input:
- A program in DirectionLang (as an ASCII string consisting of DirectionLang instructions)
- A list of pairs of integers, henceforth known as the pretty places. This list may be taken in any reasonable format.
You should then output a truthy value if the program halted at a pretty place, and a falsey value otherwise.
DirectionLang
A DirectionLang instruction is hereby defined to be either
<
: Decrement the x coordinate by 1.>
: Increment the x coordinate by 1.^
: Increment the y coordinate by 1.V
: Decrement the y coordinate by 1.S
: Skip the next instruction if the program is currently at a pretty place.
A DirectionLang program is executed by performing each instruction, in order. A DirectionLang program starts at the origin (coordinates (0, 0)
). A DirectionLang program halts when every instruction has been executed.
If a DirectionLang program ends with an S
, then its behavior is undefined.
If a DirectionLang program has no instructions, then its behavior is undefined.
DirectionLang is quite obviously not Turing complete, as there is not a way of looping.
Test cases
"<>^^" [(0, 2), (0, 0)] -> True
"<>^^" [(0, 1)] -> False
"S^>>" [(0, 0), (2, 0)] -> True
"<SS^" [(-1, 0), (-1, 1)] -> True
"<SS^" [(-1, 0), (-1, -1)] -> False
"S^>>" [(2, 0)] -> False
"S^>>V" [(2, 0)] -> True