From 8a58fb05c0c962da4d86f83b3fd3084bc9cbd5f4 Mon Sep 17 00:00:00 2001 From: pareronia <49491686+pareronia@users.noreply.github.com> Date: Wed, 6 Dec 2023 06:38:34 +0100 Subject: [PATCH] AoC 2023 Day 6 Part 2 --- README.md | 2 +- src/main/python/AoC2023_06.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bf97a90d..74f1a310 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | | ---| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| python3 | [✓](src/main/python/AoC2023_01.py) | [✓](src/main/python/AoC2023_02.py) | [✓](src/main/python/AoC2023_03.py) | [✓](src/main/python/AoC2023_04.py) | [✓](src/main/python/AoC2023_05.py) | | | | | | | | | | | | | | | | | | | | | +| python3 | [✓](src/main/python/AoC2023_01.py) | [✓](src/main/python/AoC2023_02.py) | [✓](src/main/python/AoC2023_03.py) | [✓](src/main/python/AoC2023_04.py) | [✓](src/main/python/AoC2023_05.py) | [✓](src/main/python/AoC2023_06.py) | | | | | | | | | | | | | | | | | | | | | java | [✓](src/main/java/AoC2023_01.java) | [✓](src/main/java/AoC2023_02.java) | [✓](src/main/java/AoC2023_03.java) | [✓](src/main/java/AoC2023_04.java) | | | | | | | | | | | | | | | | | | | | | | | bash | | | | | | | | | | | | | | | | | | | | | | | | | | | c++ | | | | | | | | | | | | | | | | | | | | | | | | | | diff --git a/src/main/python/AoC2023_06.py b/src/main/python/AoC2023_06.py index 8724ece9..2069eb40 100644 --- a/src/main/python/AoC2023_06.py +++ b/src/main/python/AoC2023_06.py @@ -59,12 +59,20 @@ def part_1(self, races: Input) -> Output1: return ans def part_2(self, races: Input) -> Output2: - return 0 + time = int("".join(str(r[0]) for r in races)) + distance = int("".join(str(r[1]) for r in races)) + log((time, distance)) + ans = 0 + for t in range(time + 1): + d = (time - t) * t + if d > distance: + ans += 1 + return ans @aoc_samples( ( ("part_1", TEST, 288), - # ("part_2", TEST, "TODO"), + ("part_2", TEST, 71503), ) ) def samples(self) -> None: