Magical BF 1
Time limit1sMemory limit1024 MB
Write a BF program that leaves x minus y in cell M0, where M0 and M1 hold x and y with 0 ≤ y ≤ x ≤ 200, and the grid reads correctly by rows and by columns.
- Level
Medium6 of 10
- Topics
- Implementation, Simulation
- Solved
- No attempts yet
Problem
John learned at school that in many East Asian languages texts can be written from left to right as well as from top to bottom. He wondered whether a text can be written so that it reads correctly both ways. In programming class he kept thinking about this too, and now he wants code that solves the tasks when read by rows (top to bottom and left to right) and when read by columns (left to right and top to bottom). For experiments he chose a language called BF.
The memory of a BF program is an infinite array with cells numbered from left to right (, , \ldots). Each cell contains a nonnegative integer that can be arbitrarily large. At the beginning of execution, the data pointer points to the leftmost cell ().
Execution starts from the first command. After each command, the program moves on to the next command in the sequence. There are six commands, each denoted by one character:
Help John write magical BF programs for solving the five tasks listed below.
As a solution to each task, submit an grid of BF program code (where ). The code does not have to be the same when read by rows and by columns, but it must solve the task correctly in both cases. The solution text can only contain the characters >, <, +, -, [ and ], and it must completely fill the grid. For any allowed input, the code must not execute more than million commands.
Task: The cells and of the array contain the integers and (), and all other cells contain zeros. Write the difference into the cell .
In the output, only the value in cell matters: it must be the difference of and (in this case, ). Other cells may contain any numbers (for example, , , , \ldots).