Skip to content

Commit

Permalink
day 4 part 1 done
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSchomp committed Dec 4, 2023
1 parent 073f631 commit f054ed4
Show file tree
Hide file tree
Showing 2 changed files with 228 additions and 0 deletions.
29 changes: 29 additions & 0 deletions day-04.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

part_one = part_two = 0

file = open('day-04.txt', 'r')
for line in file:
winning_numbers = set(())
row = []
line = line.strip()
card = line.split(':')
id = card[0].split(' ')[1]
(winners, yours) = card[1].split('|')

for w in winners.strip().split():
winning_numbers.add(w)

value = 0
for y in yours.strip().split():
if y in winning_numbers:
y = int(y)
if value == 0:
value = 1
else:
value *= 2

part_one += value
file.close()

print( "part_one:", part_one )
print( "part_two:", part_two )
Loading

0 comments on commit f054ed4

Please sign in to comment.