UVa 10409

From Algorithmist
Jump to navigation Jump to search

Problem 10409 - Die Game[edit]

http://uva.onlinejudge.org/external/104/10409.html

Summary[edit]

We have a dice (Die), and some commands (1-1024): north, south, east, west.

After performing the commands, what's the number in the top face of the Die?

Explanation[edit]

The initial position is: the numbers 1, 2, and 3 are seen on the top, north, and west faces, respectively.

  2
3 1 4
  5
  6

Moves[edit]

From the initial position:

north generates:

  1
3 5 4
  6
  2

south generates:

  6
3 2 4
  1
  5

east generates:

  2
6 3 1
  5
  4

west generates:

  2
1 4 6
  5
  3

Input[edit]

1
north
3
north
east
south
10
north
north
south
east
south
west
north
east
north
north
0

Output[edit]

5
1
6