Exercise 4: Movements 2

Movements 2

Let's understand what we just did: write a program.

Every program has exactly one program: a section of the code which declares the commands (actions) that we want the computer to execute on the initial board. By executing a program, we get a final board.

The syntax of a program is really simple:

  1. we write a line which says program, followed by an opening key: {
  2. next, the commands: one per line
  3. and finally, one last key which closes the one we used before }

Some examples of programs:

program {
}

(makes nothing)

program {
  Move(North)
}

(moves the head one position to the north)

program {
  Move(North)
  Move(North)
}

(moves the head two positions to the north)

Knowing this, write a program which, on a 2x4 board with the head in the initial point (the left bottom cell), moves the head three times to the north.

Inicial Final
GBB/1.0 size 2 4 head 0 0 GBB/1.0 size 2 4 head 0 3

You must sign in before submitting your solutions

Oops, your solution didn't work

  • Check that your program does not have recursion or an infinite loop
  • Check that you have an internet connection
  • Wait a while and try again

We are processing you solution

Please press F5 if results are not displayed after a few seconds