Py lion solve for day 6

This commit is contained in:
rain
2023-12-08 13:45:46 -06:00
parent d1f438eae9
commit b9fc2b4ab7
3 changed files with 72 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
import math
with open("../input.txt", "r") as fp:
input = fp.read().strip().split("\n")
race = (
int(''.join(input[0].split()[1:])),
int(''.join(input[-1].split()[1:])),
)
time = race[0]
record = race[-1]+1
min = math.ceil((time - math.sqrt(time*time - 4 * record))/2)
max = math.floor((time + math.sqrt(time*time - 4 * record))/2)
product = (max-min+1)
print(product)