-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Time: 7 15 30 | ||
Distance: 9 40 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Time: 7 15 30 | ||
Distance: 9 40 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Time: 42 68 69 85 | ||
Distance: 284 1005 1122 1341 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import math | ||
import re | ||
|
||
def solution(input, together=False): | ||
numbers = [[int(x) for x in re.sub(" +", " " if not together else "", line.split(":")[1]).strip().split(" ")] for line in input.splitlines()] | ||
time_distances = list(zip(numbers[0], numbers[1])) | ||
return math.prod([len([x for x in [(t-y)*y > d for y in range(t)] if x]) for t, d in time_distances]) | ||
|
||
def example_1(input): | ||
return solution(input) | ||
|
||
def part_1(input): | ||
return solution(input) | ||
|
||
def example_2(input): | ||
return solution(input, True) | ||
|
||
def part_2(input): | ||
return solution(input, True) |