Files
AdventOfCode2023/06/06-1.py
2023-12-06 15:23:50 +01:00

28 lines
606 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
times = []
dists = []
input_file = open("input", "r")
for line in input_file:
if line.startswith('Time:'):
times = line.strip().split(":")[1].split()
if line.startswith('Distance:'):
dists = line.strip().split(":")[1].split()
input_file.close()
winning_trys = []
for i in range(len(times)):
wins = 0
for j in range(int(times[i])+1):
if (int(times[i])-j)*j > int(dists[i]):
wins += 1
winning_trys.append(wins)
print(winning_trys)
solution = 1
for j in winning_trys:
solution *= j
print(solution)