From 2c9c027eb12661258c95a465d39633c8f64452d9 Mon Sep 17 00:00:00 2001 From: Stefan Harmuth Date: Sat, 30 Nov 2024 11:26:58 +0100 Subject: [PATCH] tiles? --- .gitignore | 5 +++++ .pre-commit-config.yaml | 16 ++++++++++++++++ README.md | 5 ++++- day21.py | 22 ++++++++++++---------- day24.py | 5 +++-- requirements.txt | 3 ++- 6 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.gitignore b/.gitignore index f295d3d..c7aed68 100644 --- a/.gitignore +++ b/.gitignore @@ -160,3 +160,8 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. .idea/ +answer_cache.json +.session +session.cookie +.aoc_tiles/* +!.aoc_tiles/tiles/ \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9d2db13 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,16 @@ +repos: + - repo: https://github.com/LiquidFun/aoc_tiles + rev: 0.6.2 + hooks: + - id: aoc-tiles + # Optionally use these arguments. Auto add tiles to git adds the tiles to git, + # possibly amends your commit by creating the tile images and updating the README. + # Language sorting shows the preference of the order of the languages to use. + # Exclude paterns are globs which can be used to exclude files when creating + # the tiles. See the customization section in the README for more flags. + # Simply remove the comments (#) below for args and the flags you want. + args: + - --auto-add-tiles-to-git=amend + - --contrast-improvement-type=dark + # - --language-sorting=py,jl,kt,rs + # - --exclude-patterns=2021/*/*.apl,2021/*/*.py,2021/*/*.cpp \ No newline at end of file diff --git a/README.md b/README.md index fbf608f..bc6bc96 100644 --- a/README.md +++ b/README.md @@ -1 +1,4 @@ -# aoc2ß23 +# Advent of Code 2ß23 + + + \ No newline at end of file diff --git a/day21.py b/day21.py index 24347ac..dcd9d0a 100644 --- a/day21.py +++ b/day21.py @@ -70,19 +70,21 @@ class Day(AOCDay): print(f"{i} = {t}") for i in [Coordinate(0, 0), Coordinate(130, 0), Coordinate(0, 130), Coordinate(130, 130)]: - t = walk(grid, i, 65) + t = walk(grid, i, 131) print(f"{i} = {t}") needed_steps = 5000 if self.is_test() else 26501365 - t = walk(grid, start, 64) + t = walk(grid, start, 65) k = walk(grid, start, len(self.getInput()) + 65) - g = walk(grid, start, 2 * len(self.getInput()) + 65) - # v = walk(grid, start, (3 * len(self.getInput())) - 1) - print(f"65={t}, 196={k}, 327={g}, {math.log(k)=}, {math.log(g)=}") - print(((k - t) / 14746) * 3) - print((g - t) / 14746) - print((g - k) / 14746) - print(g % k) - print(k / t) + w2 = walk(grid, start, 2 * len(self.getInput()) + 65) + w3 = walk(grid, start, 3 * len(self.getInput()) + 65) + w4 = walk(grid, start, 4 * len(self.getInput()) + 65) + w5 = walk(grid, start, 5 * len(self.getInput()) + 65) + w6 = walk(grid, start, 6 * len(self.getInput()) + 65) + print(f"65={t}, 196={k}, {w2=}, {w3=}, {w4=}, {w5=}, {w5=}") + print(w3 / w2) + print(w4 / w3) + print(w5 / w4) + print(w6 / w5) return "" diff --git a/day24.py b/day24.py index 5529e61..0ad81a6 100644 --- a/day24.py +++ b/day24.py @@ -1,3 +1,4 @@ +from collections import defaultdict from itertools import combinations from tools.aoc import AOCDay from tools.coordinate import Coordinate, Line @@ -29,7 +30,7 @@ class Day(AOCDay): [ (47, "input24_test"), (None, "input24"), - ] + ], ] def parse_input(self, part2: bool = False) -> list[tuple[Coordinate, Coordinate]]: @@ -63,6 +64,6 @@ class Day(AOCDay): return "" -if __name__ == '__main__': +if __name__ == "__main__": day = Day(2023, 24) day.run(verbose=True) diff --git a/requirements.txt b/requirements.txt index e58fa34..10ba718 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -shs-tools ~= 0.3 \ No newline at end of file +shs-tools ~= 0.3 +pre-commit \ No newline at end of file