Skip to content

Commit 7f304dd

Browse files
committed
Add day 4
1 parent d89de28 commit 7f304dd

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

2023/04/04.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from sys import stdin
2+
3+
lines = stdin.read().strip().split("\n")
4+
p = 0
5+
repeat = [1] * len(lines)
6+
for i, line in enumerate(lines):
7+
right, left = line.split(":")[1].split("|")
8+
shared = len(set(right.split()) & set(left.split()))
9+
if shared:
10+
p += 2**(shared - 1)
11+
for j in range(i+1, min(i+1+shared, len(lines))):
12+
repeat[j] += repeat[i]
13+
print(p, sum(repeat), sep='\n')

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<!-- AOC TILES BEGIN -->
66
<h1 align="center">
7-
2023 - 6
7+
2023 - 8
88
</h1>
99
<a href="2023/01/01.py">
1010
<img src="Media/2023/01.png" width="161px">
@@ -15,6 +15,9 @@
1515
<a href="2023/03/03.py">
1616
<img src="Media/2023/03.png" width="161px">
1717
</a>
18+
<a href="2023/04/04.py">
19+
<img src="Media/2023/04.png" width="161px">
20+
</a>
1821
<h1 align="center">
1922
2022 - 50 ⭐
2023
</h1>

0 commit comments

Comments
 (0)