Skip to content

Commit 1eb0ba2

Browse files
committed
Add day 9
1 parent b859e91 commit 1eb0ba2

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

.aoc_tiles/tiles/2023/08.png

-279 Bytes
Loading

.aoc_tiles/tiles/2023/09.png

9.92 KB
Loading

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/LiquidFun/aoc_tiles
3-
rev: 0.3.3
3+
rev: 0.3.4
44
hooks:
55
- id: aoc-tiles
66
args:

2023/09/09.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from sys import stdin
2+
3+
lines = stdin.read().strip().split('\n')
4+
5+
first = last = 0
6+
for line in lines:
7+
diff = [int(a) for a in line.split()]
8+
sign = 1
9+
while any(diff):
10+
last += diff[-1]
11+
first += diff[0] * sign
12+
sign *= -1
13+
diff = [b - a for a, b in zip(diff, diff[1:])]
14+
15+
print(first, last, sep='\n')

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<!-- AOC TILES BEGIN -->
66
<h1 align="center">
7-
2023 - 16
7+
2023 - 18
88
</h1>
99
<a href="2023/01/01.rs">
1010
<img src=".aoc_tiles/tiles/2023/01.png" width="161px">
@@ -27,9 +27,12 @@
2727
<a href="2023/07/07.py">
2828
<img src=".aoc_tiles/tiles/2023/07.png" width="161px">
2929
</a>
30-
<a href="2023/08/08.rs">
30+
<a href="2023/08/08.py">
3131
<img src=".aoc_tiles/tiles/2023/08.png" width="161px">
3232
</a>
33+
<a href="2023/09/09.py">
34+
<img src=".aoc_tiles/tiles/2023/09.png" width="161px">
35+
</a>
3336
<h1 align="center">
3437
2022 - 50 ⭐
3538
</h1>

0 commit comments

Comments
 (0)