Skip to content

Commit

Permalink
Day 6 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
gillesmag committed Dec 6, 2023
1 parent eaebcf4 commit 81ddff2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 2023/examples/day06-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Time: 7 15 30
Distance: 9 40 200
2 changes: 2 additions & 0 deletions 2023/examples/day06-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Time: 7 15 30
Distance: 9 40 200
2 changes: 2 additions & 0 deletions 2023/inputs/day06.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Time: 42 68 69 85
Distance: 284 1005 1122 1341
19 changes: 19 additions & 0 deletions 2023/solutions/day06.py
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)

0 comments on commit 81ddff2

Please sign in to comment.