Rolling a 1x1x2 block
This challenge is inspired by the game Bloxorz. Like that game, there is a 1x1x2 block, which may be moved on a square grid in any of the four cardinal directions. It moves by rotating 90 degrees about one of its edges which is touching the ground. Initially, the block is standing upright on a single square in a square grid. After some sequence of moves, determine whether it is:
- Standing upright on the starting square,
- Laying half-on, half-off the starting square, or
- Not on the starting square at all.
Input
Input is given as a string consisting of the characters F
, B
, L
, and R
, which represent moving forward, backward, left, and right.
Output
Output can be 1, 0.5, or 0, representing the fraction of the block resting on the starting square. Your program may use some other set of three distinct outputs, as long as they consistently represent the three possibilities.
Test cases
"FFFBBB" -> 1
"" -> 1
"FRRRBLL" -> 1
"FRBL" -> 0.5
"FRBBL" -> 0