File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 1111| [ Day 7: No Space Left On Device] ( https://adventofcode.com/2022/day/7 ) | [ py] ( /day07/main.py ) , [ alt] ( /day07/alt.py ) |
1212| [ Day 8: Treetop Tree House] ( https://adventofcode.com/2022/day/8 ) | [ py] ( /day08/main.py ) |
1313| [ Day 9: Rope Bridge] ( https://adventofcode.com/2022/day/9 ) | [ py] ( /day09/main.py ) |
14+ | [ Day 10: Cathode-Ray Tube] ( https://adventofcode.com/2022/day/10 ) | [ py] ( /day10/main.py ) |
1415
1516My solutions from previous years:
1617* [ r0f1/adventofcode2020] ( https://github.com/r0f1/adventofcode2020 )
Original file line number Diff line number Diff line change 1+ instructions = open ("input.txt" ).readlines ()
2+
3+ x = 1
4+ c = 0
5+ hist = [x ]
6+ output = ""
7+
8+ pix = lambda c , x : "#" if abs (c - x ) <= 1 else "."
9+
10+ for instr in instructions :
11+ output += pix (c , x )
12+ c = (c + 1 ) % 40
13+ if instr .startswith ("addx" ):
14+ output += pix (c , x )
15+ c = (c + 1 ) % 40
16+ hist .append (x )
17+ x += int (instr .split ()[1 ])
18+ hist .append (x )
19+
20+ print (sum (i * hist [i - 1 ] for i in range (20 , 221 , 40 )))
21+ for row in range (0 , 6 ):
22+ print (output [row * 40 :(row + 1 )* 40 ])
You can’t perform that action at this time.
0 commit comments