diff --git a/2022/10/input b/2022/10/input new file mode 100644 index 0000000..f93ec2c --- /dev/null +++ b/2022/10/input @@ -0,0 +1,143 @@ +noop +noop +noop +addx 5 +addx 1 +addx 4 +addx 1 +noop +addx 4 +noop +addx 1 +addx 4 +addx 8 +addx -7 +addx 3 +addx 1 +noop +addx 4 +addx 2 +addx 5 +addx -1 +noop +addx -37 +noop +noop +addx 3 +addx 2 +addx 13 +addx 12 +addx -15 +addx -2 +addx 2 +addx -11 +addx 18 +addx 2 +addx -15 +addx 16 +addx 5 +addx 2 +addx 5 +noop +noop +noop +addx 3 +addx -2 +addx -38 +noop +addx 3 +addx 4 +noop +noop +noop +noop +noop +addx 5 +addx 5 +noop +noop +addx 21 +addx -17 +addx 6 +noop +noop +noop +noop +addx 5 +noop +noop +noop +noop +noop +addx 3 +addx 5 +addx -38 +noop +noop +addx 5 +addx -2 +addx 1 +addx 7 +noop +addx 22 +addx -18 +addx -11 +addx 27 +addx -13 +addx 2 +addx 5 +addx -8 +addx 9 +addx 2 +noop +addx 7 +noop +addx 1 +noop +addx -38 +noop +addx 2 +addx 5 +addx -3 +noop +addx 8 +addx 11 +addx -6 +noop +addx 24 +addx -31 +addx 10 +addx 2 +addx 5 +addx 3 +noop +addx 2 +addx -29 +addx 21 +addx 11 +addx 5 +addx -39 +addx 4 +addx -2 +addx 2 +addx 7 +noop +addx -1 +addx 2 +noop +addx 4 +noop +addx 1 +addx 2 +addx 5 +addx 2 +noop +noop +addx -6 +addx 9 +addx -18 +addx 25 +addx 3 +noop +addx -17 +noop diff --git a/2022/10/part1 b/2022/10/part1 new file mode 100755 index 0000000..fc86303 --- /dev/null +++ b/2022/10/part1 @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +CLOCK = 1 +X = 1 + +X_VALUES = [] + +with open('input') as f: + for line in f: + ins, *args = line.rstrip().split(" ") + + if ins == "noop": + CLOCK += 1 + X_VALUES.append(X) + elif ins == "addx": + CLOCK += 2 + X_VALUES.append(X) + X_VALUES.append(X) + X += int(args[0]) + +print( + (X_VALUES[19] * 20) + + (X_VALUES[59] * 60) + + (X_VALUES[99] * 100) + + (X_VALUES[139] * 140) + + (X_VALUES[179] * 180) + + (X_VALUES[219] * 220) +) diff --git a/2022/10/part2 b/2022/10/part2 new file mode 100755 index 0000000..792237f --- /dev/null +++ b/2022/10/part2 @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +CLOCK = 0 +X = 1 +OUT = [] + +def clock(): + global CLOCK, X, OUT + pos = CLOCK%40 + + if X == pos or X-1 == pos or X+1 == pos: + OUT.append('#') + else: + OUT.append('.') + + if pos == 39: + OUT.append("\n") + + CLOCK += 1 + +with open('input') as f: + for line in f: + ins, *args = line.rstrip().split(" ") + + if ins == "noop": + clock() + elif ins == "addx": + clock() + clock() + X += int(args[0]) + +print(''.join(OUT)) diff --git a/README.md b/README.md index bc7085c..1324e59 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ a programming language I'm interested in learning more about. 2018, 2019, and 2020 were in their own separate repositories, but have been `git subtree`'d into this one - no point creating a new repository every year. -* [2022](https://code.ur.gs/lupine/advent-of-code/src/branch/main/2022) 🌟 `18` - Python +* [2022](https://code.ur.gs/lupine/advent-of-code/src/branch/main/2022) 🌟 `20` - Python * [2021](https://code.ur.gs/lupine/advent-of-code/src/branch/main/2021) 🌟 ` 5` - Python * [2020](https://code.ur.gs/lupine/advent-of-code/src/branch/main/2020) 🌟 `20` - Javascript * [2019](https://code.ur.gs/lupine/advent-of-code/src/branch/main/2019) 🌟 `22` - Zig @@ -18,6 +18,6 @@ a programming language I'm interested in learning more about. * 2016 🌟 `16` - LISP? * 2015 🌟 ` 9` - Ruby? -Total: 🌟 `96` +Total: 🌟 `98` Maybe I'll backfill some of the old years one day.