import sys
from dataclasses import dataclass, field
from collections import namedtuple

DEBUG = True
debug_padding = 24

def debug_print(printname, *args):
    if DEBUG:
        print(f"{'DEBUG::'+printname:<{debug_padding}}", *args)


RaceParams = namedtuple("Point", "time distance")



print("Parsing Input:")
print("")
print("===================================\n");

FILENAME = "/home/icaema/Public/advent-of-code/day-06/data/p01data.txt"
f = open(FILENAME, "r")

#for line in sys.stdin:
lines = f.readlines()
p_time = lines[0][5:].split()
p_farthest = lines[1][9:].split()

races = [RaceParams(int(p_time[i]), int(p_farthest[i])) for i in range(len(p_time))]



def calc_distance(totaltime, sleeptime):
    return (totaltime-sleeptime)*sleeptime



def invcalc_distance(totaltime, distance):
    return (totaltime + distance*distance)/distance

result = 1

for race in races:
    winning_sleeptimes = 0
    for i in range(race.time):
        if calc_distance(race.time, i) < race.distance:
            winning_sleeptimes += 1
    winning_sleeptimes = len([slt for slt in range(race.time) if calc_distance(race.time, slt) > race.distance])
    print(winning_sleeptimes)
    result *= winning_sleeptimes





print("")
print(" Proccessing:")
print("===================================\n");
# Insert Processing Code






print("")
print(" Calculate Answer:")
print("===================================\n");






print("")
print(" Answer:")
print("===================================\n");
print(f"Answer: \n{result}");