File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 6
6
| [ Day 2: Rock Paper Scissors] ( https://adventofcode.com/2022/day/2 ) | [ py] ( /day02/main.py ) , [ alt1] ( /day02/alt1.py ) , [ alt2] ( /day02/alt2.py ) |
7
7
| [ Day 3: Rucksack Reorganization] ( https://adventofcode.com/2022/day/3 ) | [ py] ( /day03/main.py ) |
8
8
| [ Day 4: Camp Cleanup] ( https://adventofcode.com/2022/day/4 ) | [ py] ( /day04/main.py ) |
9
+ | [ Day 5: Supply Stacks] ( https://adventofcode.com/2022/day/5 ) | [ py] ( /day05/main.py ) |
9
10
10
11
My solutions from previous years:
11
12
* [ r0f1/adventofcode2020] ( https://github.com/r0f1/adventofcode2020 )
Original file line number Diff line number Diff line change
1
+ with open ("input.txt" ) as f :
2
+ lines = f .readlines ()
3
+
4
+ idx = 0
5
+ for i , l in enumerate (lines ):
6
+ if len (l ) == 1 :
7
+ idx = i
8
+ break
9
+
10
+ crates = list (zip (* [list (l [1 ::4 ]) for l in lines [i - 2 ::- 1 ]]))
11
+ crates = [[k for k in c if k != ' ' ] for c in crates ]
12
+
13
+ moves = [l .split (" from " ) for l in lines [idx + 1 :]]
14
+ for a , b in moves :
15
+ idx_s , idx_t = [int (k )- 1 for k in b .split (" to " )]
16
+ s , t = crates [idx_s ], crates [idx_t ]
17
+ r = [s .pop () for _ in range (int (a [5 :]))]
18
+ #t.extend(r) # Part 1
19
+ t .extend (r [::- 1 ]) # Part 2
20
+
21
+ print ("" .join (c [- 1 ] for c in crates ))
You can’t perform that action at this time.
0 commit comments