File tree 2 files changed +27
-3
lines changed 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -39,12 +39,27 @@ def process_move_multiple(move, stacks):
39
39
from_ = int (from_ )
40
40
to = int (to )
41
41
stacks [to ].extend (stacks [from_ ][- num :])
42
- print (from_ , stacks [from_ ][- num :], to )
42
+ # print(from_, stacks[from_][-num:], to)
43
43
del stacks [from_ ][- num :]
44
44
45
45
46
46
with open ('input' ) as f :
47
- inputs = (line .rstrip ('\n ' ) for line in f )
47
+ file = [line .rstrip ('\n ' ) for line in f ]
48
+ inputs = (line for line in file )
49
+
50
+ stacks = read_stacks (inputs )
51
+ # print(stacks)
52
+
53
+ for move in inputs :
54
+ if move .strip ():
55
+ process_move_single (move , stacks )
56
+ # print(stacks)
57
+ top_crates = [stacks [crate ][- 1 ]
58
+ for crate in range (1 , 9 + 1 ) if stacks [crate ]]
59
+ # print(top_crates)
60
+ print ('' .join (top_crates ))
61
+
62
+ inputs = (line for line in file )
48
63
49
64
stacks = read_stacks (inputs )
50
65
# print(stacks)
@@ -55,5 +70,5 @@ def process_move_multiple(move, stacks):
55
70
# print(stacks)
56
71
top_crates = [stacks [crate ][- 1 ]
57
72
for crate in range (1 , 9 + 1 ) if stacks [crate ]]
58
- print (top_crates )
73
+ # print(top_crates)
59
74
print ('' .join (top_crates ))
Original file line number Diff line number Diff line change
1
+ [D]
2
+ [N] [C]
3
+ [Z] [M] [P]
4
+ 1 2 3
5
+
6
+ move 1 from 2 to 1
7
+ move 3 from 1 to 3
8
+ move 2 from 2 to 1
9
+ move 1 from 1 to 2
You can’t perform that action at this time.
0 commit comments