package day06

type Race struct {
	Time     int
	Distance int
}

func Part1(input string) int {
	var Races []Race
	Races = append(Races, Race{56, 546})
	Races = append(Races, Race{97, 1927})
	Races = append(Races, Race{78, 1131})
	Races = append(Races, Race{75, 1139})

	total := 1
	for _, r := range Races {
		halfTime := r.Time / 2
		for i := 0; i <= halfTime; i++ {
			raceDis := i * (r.Time - i)
			if raceDis > r.Distance {
				total = total * (r.Time - (i * 2) + 1)
				break
			}
		}
	}
	return total
}

func Part2(input string) int {
	r := Race{56977875, 546192711311139}
	halfTime := r.Time / 2
	for i := 0; i <= halfTime; i++ {
		raceDis := i * (r.Time - i)
		if raceDis > r.Distance {
			return r.Time - (i * 2) + 1

		}
	}
	return -1
}
