You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
804 B

lines = open('inputs/day6.txt').readlines()
time = [int(x) for x in lines[0].split()[1:]]
dist = [int(x) for x in lines[1].split()[1:]]
time2 = int("".join(lines[0].split()[1:]))
dist2 = int("".join(lines[1].split()[1:]))
def gained_dist(push_t: int, trvl_t: int) -> int:
return trvl_t * push_t
def record_beat(record: int, t: int, push_t: int) -> bool:
trvl_t = t - push_t
return gained_dist(push_t, trvl_t) > record
def count_wins(t: int, d: int) -> int:
counter = 0
for i in range(1, t+1):
counter += record_beat(d, t, i)
return counter
wins = []
win_counter = 1
for t, d in zip(time, dist):
wins.append(count_wins(t,d))
for w in wins:
win_counter *= w
print(f"Solution to Part 1: {win_counter}")
print(f"Solution to Part 2: {count_wins(time2, dist2)}")