Introduction
Jonny wants to play Frogger. However, he's not very good. In fact, he will only try to move forward, and only after the platforms have moved.
Find out if Jonny's frog manages to reach the end of the path or if it dies on its way.
Challenge
The program will be receiving as input a Frogger grid composed by 0s and 1s, with the following format:
- The grid will be of a random width and length, and at least 3x3
1represents platforms0represents waterFrepresents the starting position of the frog- Every first and last line of the grid will be composed by only
1s, and will not move, and the frogFwill be placed at random on the last line - Every intermediate layer will always be moving, and will have a
<or>at the end of every line indicating if it moves left or right
Replacing these symbols with your own is allowed, as long as they're all distinct and you specify the replacements in your answer.
The input may be in any compatible format (string with line breaks, array of strings, array of characters, ...).
Challenge Rules
- Every turn, all platforms will move one square, based on the direction indicated by the
<or>sign - Platforms reappear on the other side of the grid if they get pushed off "screen"
- If the frog is on a moving platform, it will move along with it
- After that, the frog will jump one square towards the top row. The frog will move every turn.
- The frog dies if it jumps in water (
0) or it touches the side of the grid along with a moving platform
Your program has to output a truthy value if the frog survives and a falsy value otherwise.
This is code-golf, so the shortest answer in bytes win. Standard loopholes apply.
Examples
Example 1
Input
11111
00111>
00101<
1F111
Output
1
Execution
Turn 1:
11111
10011
01010
1F111
11111
10011
0F010
11111
Turn 2:
11111
11001
F0100
11111
11111
F1001
10100
11111
Turn 3:
11111
1F100
01001
11111
1F111
11100
01001
11111
Example 2
Input
11111
00100<
00100<
1F111
Output
0
Execution
Turn 1:
11111
01000
01000
1F111
11111
01000
0F000
11111
Turn 2:
11111
10000
F0000
11111
11111
F0000
10000
11111
Turn 3:
11111
00001
00001
11111
<or>so we can take rectangular arrays as input? By the way, nice challenge! \$\endgroup\$<or>at the end. \$\endgroup\$0in front of it, or will it wait for the next1? If it can wait, will it go forward on every1, or can it wait smartly? I.e. with the test case11111 00001< 00011< 11F11, will it be falsey because it jumps in the water (pastebin of steps); will it be falsey because it moves out of frame (pastebin of steps); or will it be truthy because it waits smartly for the second platform before jumping forward (pastebin of steps)? \$\endgroup\$0. \$\endgroup\$