diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-12-06 22:07:37 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-12-06 22:07:37 +0100 |
commit | 792b94cfebae617b36361aa2779dc73b10e45069 (patch) | |
tree | ca06d17010dc3b9c893d6b944e4597030672a308 | |
parent | da68ad27aecdbd19ce234eacd854d300848fed7c (diff) |
day 6 part 1
-rwxr-xr-x | 06/main.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/06/main.py b/06/main.py new file mode 100755 index 0000000..9951621 --- /dev/null +++ b/06/main.py @@ -0,0 +1,22 @@ +#!/bin/python3 +import sys + +times = [int(x) for x in input().split(":")[1].split()] +distances = [int(x) for x in input().split(":")[1].split()] +races = [(times[i], distances[i],) for i in range(len(times))] + +def distance_for_race_len(race_len, hold_time): + if hold_time <= 0: return 0 + if hold_time >= race_len: return 0 + return round((race_len - hold_time) * hold_time) + +output = 1 +for max_time, record_dist in races: + possible_distances = [distance_for_race_len(max_time, x) for x in range(max_time)] + possible_distances = list(enumerate(possible_distances)) + possible_distances = [p for p in possible_distances if p[1] > record_dist] + + output *= len(possible_distances) + +print(f">> {output}") + |