File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -7,27 +7,40 @@ def self.go
7
7
8
8
def initialize ( input = nil )
9
9
@input = input || real_input
10
- @stacks = parse_stacks
11
10
@moves = parse_moves
12
11
end
13
12
14
13
# @example
15
14
# day.part1 => "CMZ"
16
15
def part1
16
+ stacks_9000 = parse_stacks
17
+
17
18
@moves
18
19
. each { |step |
19
20
step [ :quantity ] . times {
20
- @stacks [ step [ :to ] ] . push ( @stacks [ step [ :from ] ] . pop )
21
+ stacks_9000 [ step [ :to ] ] . push ( stacks_9000 [ step [ :from ] ] . pop )
21
22
}
22
23
}
23
24
24
- @stacks
25
+ stacks_9000
25
26
. values
26
27
. map ( &:last )
27
28
. join ( "" )
28
29
end
29
30
31
+ # @example
32
+ # day.part2 => "MCD"
30
33
def part2
34
+ stacks_9001 = parse_stacks
35
+ @moves
36
+ . each { |step |
37
+ stacks_9001 [ step [ :to ] ] += stacks_9001 [ step [ :from ] ] . pop ( step [ :quantity ] )
38
+ }
39
+
40
+ stacks_9001
41
+ . values
42
+ . map ( &:last )
43
+ . join ( "" )
31
44
end
32
45
33
46
# @example
You can’t perform that action at this time.
0 commit comments