Problem 101 -- The Blocks Problem

read problem

Tips

Divide and conquer.

The commands can be decomposed into series of simplier movements. Built a handful of these basic functions and combine them to form the four specified commands.

My data structure is built on a 25 x 25 char array with simple stack operations.

 

Test Cases

Input

24
move 4 over 8
move 18 over 3
move 7 over 0
move 13 over 9
move 23 onto 5
pile 5 over 13
pile 13 onto 22
move 19 onto 8
pile 16 over 0
move 22 onto 22
pile 22 over 2
pile 16 onto 11
move 4 onto 23
pile 19 onto 0
move 15 onto 17
pile 20 onto 23
pile 4 over 4
pile 15 onto 20
move 14 over 1
pile 5 over 22
move 17 over 23
pile 12 onto 23
pile 15 over 22
move 17 onto 10
move 1 onto 14
pile 19 onto 13
pile 9 onto 9
move 1 onto 0
move 23 over 6
move 23 over 16
pile 20 over 1
move 15 onto 23
pile 15 onto 2
move 22 over 7
move 14 over 20
pile 9 onto 1
pile 16 onto 8
pile 8 over 9
pile 9 onto 4
move 11 onto 14
move 15 onto 1
move 5 onto 1
move 7 over 4
move 9 onto 14
pile 19 onto 0
move 19 onto 18
move 6 over 10
pile 2 onto 13
pile 3 onto 15
pile 14 over 2
quit

Output

0: 0
1: 1
2:
3:
4: 4
5: 5
6:
7: 7
8: 8
9:
10: 10 17 6
11: 11
12: 12
13: 13 2 14 9
14:
15: 15 3 18 19
16: 16
17:
18:
19:
20: 20
21: 21
22: 22
23: 23