Pebbling Odometer 2
Time limit1sMemory limit512 MB
Write a program that ends on (0, 0) if x is at most y and on (0, 1) otherwise, leaving both pebble counts unchanged.
- Level
Hard8 of 10
- Topics
- Simulation, Implementation
- Solved
- No attempts yet
Operation grid
The odometer moves on an imaginary square grid of unit cells. Each cell can contain at most 15 pebbles and is identified by a pair of coordinates (row, column), where each coordinate is in the range 0, ..., 255. Given a cell , the adjacent cells are (if they exist) , , and . Any cell on the first or last row, or on the first or last column, is called a border. The odometer always starts at cell (the north-west corner), facing north.
Basic commands
The odometer runs the commands in the order they appear in the program. A program has at most one command per line. Empty lines are ignored. The symbol # starts a comment, and any text after it up to the end of the line is ignored. If the odometer reaches the end of the program, execution stops.
left: turn 90 degrees to the left (counter clockwise) and stay in the current cell.right: turn 90 degrees to the right (clockwise) and stay in the current cell.move: move one unit forward into the adjacent cell. If the border in that direction has already been reached, this command has no effect.get: remove one pebble from the current cell. If the cell has no pebbles, this command has no effect.put: add one pebble to the current cell. If the cell already has 15 pebbles, this command has no effect. The odometer never runs out of pebbles.halt: terminate the execution.
Labels, borders and pebbles
Labels are case-sensitive strings of at most 128 symbols chosen from a to z, A to Z, and 0 to 9. In the descriptions below, L stands for any valid label.
L:declares the location of labelLin the program. All declared labels must be unique. A declaration has no effect on the odometer.jump Ljumps unconditionally to the line with labelL.border Ljumps to labelLif the odometer is on a border and faces the edge of the grid, so that amovewould have no effect. Otherwise, execution continues normally.pebble Ljumps to labelLif the current cell contains at least one pebble. Otherwise, execution continues normally.
Program size and execution length
The size of a program is the number of commands in it. Label declarations, comments and blank lines are not counted. The execution length is the number of steps performed. Every command execution counts as one step, whether or not the command had an effect. Label declarations, comments and blank lines do not count as steps.
Task
At the start, cell holds pebbles and cell holds pebbles. All other cells are empty. Write a program that terminates with the odometer in cell if , and in cell otherwise. At the end, cell must contain exactly pebbles and cell must contain exactly pebbles. Remember that no cell can hold more than 15 pebbles.
Limits
The program size must be at most 200. The execution length must be at most 2000.