AdventOfCode/2023/day6/part1.py

47 lines
1013 B
Python
Raw Normal View History

2023-12-06 17:38:30 +01:00
#!/bin/python3
import sys
from pprint import pprint
2023-12-06 19:08:19 +01:00
import numpy as np
2023-12-06 17:38:30 +01:00
input_f = sys.argv[1]
arr = []
from aocd import get_data
2023-12-06 19:08:19 +01:00
#print(get_data(day=6,year=2023))
maps = open(input_f).read().splitlines()
maps = [l.split() for l in maps]
pprint(maps)
total_winnings = []
for i in range(0,len(maps[0])):
if i == 0:
continue
time = int(maps[0][i])
max_dist = int(maps[1][i])
hold = 0
dist = 0
total_winnings.append(0)
print(total_winnings)
print('Start\t',end='')
print(maps[0][i],maps[1][i])
print('Time\tDist\tHold')
for j in range(1,int(maps[0][i])+1):
while time > 0:
time -= 1
hold += 1
dist = hold * time
won = False
print(str(time)+ '\t' + str(dist) + '\t' + str(hold) + '\t',end='')
if dist > max_dist:
total_winnings[i-1] += 1
print('won')
else:
print()
print(np.prod(total_winnings))
print(total_winnings)