From 1e68260c9da2fed451407c007b9f2e2bd00aca99 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Mon, 16 Dec 2024 01:39:42 -0600 Subject: [PATCH] wip --- 2024/day16/input.txt | 141 +++++++++++++++++++++++++++++++++++++++ 2024/day16/input.txt.h | 15 +++++ 2024/day16/sample1.txt | 15 +++++ 2024/day16/sample1.txt.h | 15 +++++ 2024/day16/solution.c | 11 +++ dijkstra.c | 32 +++++++++ dijkstra.h | 0 heap.c | 47 +++++++++++++ heap.h | 13 +++- input_dreamcast.inc | 10 +++ linear_algebra.c | 27 -------- memory.c | 11 +++ memory.h | 1 + runner.inc | 7 ++ solutions.mk | 5 +- test/run.sh | 19 ++++++ test/runner.h | 27 ++++++++ test/test_heap.c | 21 ++++++ test/test_memory | Bin 0 -> 27840 bytes test/test_memory.c | 23 +++++++ 20 files changed, 411 insertions(+), 29 deletions(-) create mode 100644 2024/day16/input.txt create mode 100644 2024/day16/input.txt.h create mode 100644 2024/day16/sample1.txt create mode 100644 2024/day16/sample1.txt.h create mode 100644 2024/day16/solution.c create mode 100644 dijkstra.c create mode 100644 dijkstra.h create mode 100644 test/run.sh create mode 100644 test/runner.h create mode 100644 test/test_heap.c create mode 100755 test/test_memory create mode 100644 test/test_memory.c diff --git a/2024/day16/input.txt b/2024/day16/input.txt new file mode 100644 index 0000000..2e1e1ec --- /dev/null +++ b/2024/day16/input.txt @@ -0,0 +1,141 @@ +############################################################################################################################################# +#.............#...#...........#...#...................#.........#...........#...................................#.............#.......#....E# +#.#####.#####.#.#.#.###.#####.#.#.#.#.#########.#####.#.#######.#.#########.#######.###.###.###.#.#######.#.###.#.#########.#.#####.#.#.#.#.# +#.#...#...#.#...#.#...#.....#.#.#.#.#.....#.....#...#...#.......#...#.....#.....#...#.#.....#.#.#.#.....#.#...#.#.#.#.......#...#...#.#.#.#.# +###.#.#.#.#.###.#.###.#.###.#.#.#.#.#.###.#.#####.#######.#########.###.#######.#.###.#######.#.#.#####.#.###.#.#.#.#.#########.#.###.#.#.#.# +#...#.#.#.#...#.....#...#...#...#...#.#.#...#...#.......#.........#...#.........#.#.#.........#.#.......#.#...#.#.#.#.....#.....#.#...#.#.#.# +#.###.###.#.###.#########.#####.#####.#.#####.#.#.#.#############.#.#.#####.#####.#.#.###.###.#.###.#####.#.###.#.#.#####.###.###.#.###.#.### +#.#.......#.....#.....#...#.....#.....#.......#...#.............#.#.#.....#.#.....#.#...#...#.#.#...#.....#.#.#.#.....#.#...#...#.#.#...#...# +#.#########.###.#.#.###.###.###.#.#####.#################.#######.#.#####.#.#.#####.###.###.#.#.###.#.#####.#.#.#####.#.###.###.#.###.#.#.#.# +#.#...#.....#.#...#...#.#.#.#.#.#.........#.............#...#.....#.....#.#.#...#...#...#...#.#...#.#.#...#...#...........#.#.............#.# +#.#.#.#####.#.#.#####.#.#.#.#.#.#######.#.#.#######.###.###.#.#######.###.#.###.#.#.#.#.#.###.###.###.#.#.###.###########.#.#.#####.###.#.#.# +#...#.....#...#...#...#.#.#...#.........#...#.....#...#.#...#...#.#...#...#.....................#...#...#...#.......#...#.#.#.#.......#.#...# +#.#######.#####.###.#.#.#.#.#####.#####.#####.###.#####.#.#####.#.#.###.#########.#.#.#.###.#######.#.#.#.#####.#####.#.#.#.###.#.#####.#.### +#.#.....#.....#.#...#.#.#...#.....#...#.#.#...#.....#...#.....#.#...#...#.........#.#.....#.#.......#...#.......#.....#.#.#...#...#.....#...# +#.#.###.###.#.#.#.###.#.#.###.#####.#.#.#.#.#######.#.#######.#.###.#.###.###########.#.###.#.###########.#######.###.#.#.###.#.#.#.###.#.#.# +#...#.#.#...#...#.#...#.#...#.#.....#.#...#.....#.#...#.......#...#.#.#.#.......#.....#...#...#.........#...#.....#.#...#...#.#.#...#.....#.# +#####.#.###.#####.#.###.#####.#.###.#.#.#.#####.#.#.#####.###.###.###.#.#.#####.#.#####.#.#.###.#######.#####.#####.#.###.###.#.#.###.#####.# +#.....#.....#.....#...#.#.....#...#.#.#.....#.......#...#...#.#...#...#...#.......#.....#.#.#...#.............#.....#.#.#.#...#.#.#...#...#.# +#.#########.#.#######.#.#.#########.###.#####.#######.#.###.###.###.###.###.###.#.#.#####.#.#.#.#.#######.###.###.###.#.#.#.###.#.#.###.###.# +#.#.......#.#.......#.#...#.......#...#.#.........#...#...#...........#...#.......#.#...#.......#.........#.......#...#...#.....#.......#...# +#.#.#.###.#.#######.#######.#####.###.#.#.#.#####.#.#####.#.#########.###.#########.#.#.#.###########.#.###.###.#.#.###.#########.#######.#.# +#...#.#...#.#.....#.#.......#.........#.#.#.....#...#.....#...#.....#...#.#...#.....#.#.#...#.......#...#...#...#.....#.....#.......#.....#.# +#####.#.###.#####.#.#.###.###.#######.#.#.#####.#.###.#######.#.###.#.#.#.#.###.#.###.#.###.#######.#####.###.###.###.#####.#####.#.#.#####.# +#.....#...#.....#.#...#...#...#.......#.#.#.....#.#...#...#...#.#...#.#.....#...#.....#...#.......#.....#...#.#.....#...#.#.........#.....#.# +#.#.#######.###.#.#####.###.#.#.#######.#.###.#####.###.#.#####.#.###.#.#####.###.#######.#######.#.#.###.#.#.#########.#.#####.#.#######.#.# +#.#.#...........#...#...#...#...#.....#.#...#.......#...#.......#...#.....#...#.#...#...........#.#.#...........#.....#.#.#.....#.........#.# +#.#.#.#####.#######.#.#####.#####.###.#.###.#####.###.###########.#.#######.###.#.#.###.#####.###.#.###.#.#.###.#.###.#.#.#.###.#.#########.# +#.#.#...............#.....#.#.....#...#...#...#...#...#...#.....#.#...........#.#.#.....#.....#...#.#.#.....#...#...#.....#.#.....#.....#...# +#.#.#.#.#.#.#######.#####.#.#.#####.#####.###.#####.#####.#.###.#.#######.###.#.#.#####.#.#####.###.#.#######.#.###.#.#.#.#.#.#.#.###.###.### +#.#.#.#.#.#.......#.....#.#.#.....#.......#.#.....#...#...#...#.#.......#.#...#...#.....#.....#.#...#.......#.#...#.#.#.#...#.#.....#.......# +#.###.#.###.#####.#######.###.#.###########.#.#.#.###.#.#####.#.###.#####.#.###.###.###.#######.#.#.#####.#.#.#####.#.#.#####.#.###.#######.# +#.....#...#.....#...#...#...#.#.#.....#.....#...#...#.#.#.....#...#.#.....#.#.....#.#...#.....#.#...#...#.#.#.......#.........#...#.......#.# +#.#######.#.###.###.#.#.###.#.#.#.#.###.#.#.#####.###.#.#.#######.#.#.###.#.#####.#.###.#.###.#.#.###.#.#.#.#######.#########.#.#.#######.### +#.....#...#.....#.#...#...#.#.#.#.#.....#.#...#...#...#.#.....#.#.#.#...#.#...#...#...#.#.#...#.#.#...#.#.#...#...#.#.....#.............#...# +#####.#.#.#.#####.#######.#.#.#.#.#######.###.#.###.###.#####.#.#.###.#.#####.#######.###.#.###.#.#.###.#.###.#.#.###.###.#.###.###.#######.# +#.#...#.#.#.#...#...........#.#...#...#.#...#.#...#...#...#.#...#...#.#.#...#.#.....#.#...#.....#...#.....#...#.#.....#.#.#.......#.#.....#.# +#.#.###.#.#.###.#.###########.#.###.#.#.###.#.###.###.#.#.#.#.#.###.###.#.#.#.#.###.#.#.#############.#########.#######.#.###.#.###.#.###.#.# +#...#...#.#.#...#.#...........#.....#.#.#...#...#...#...#.#.#.#...#.#...#.#.....#.....#.#...#.........#.........#.......#...#.#.....#.#...#.# +#.###.#.###.#.###.#.#######.#.#######.#.#.#####.###.#####.#.#.#.###.#.#.#.#######.###.#.#.#.#####.#####.#########.#####.###.#.#.#####.#.###.# +#...#.#...#.#.....#.#.....#...#...#...#.#.#.#.....#...#...#.#.#...#.#.#.#...#.......#.#...#.....#...#...#.....#...#...#...#.....#.....#.#...# +###.#.###.#.#######.#.#########.#.###.#.#.#.#.###.#.###.###.#.#.#.#.#.#.###.#.#####.#####.#####.#.#.#.#####.#.#.#.#.#.###.###.#.#.#####.###.# +#...#.#...#.........#...........#...#...#.#.......#.....#...#.#.#.....#.#...#.....#.#...#.#.........#.#.....#.#.#...#.....#...#.#.#...#.....# +#.#.#.#.#########.#######.#########.###.#.#.#####.#######.###.###########.#######.#.#.#.###.#####.#.#.#.#####.#.#.#.#######.#.#.#.#.#.#####.# +#.#...#.#...............#.....#...#.#.#.#.#...#.#...#.......#...#.........#.#...#.#...#.....#...#...#.#.#...#.#.#.#...#.#...#.#.#...#.#.#...# +#.#.###.#.#######.#####.#.###.#.#.#.#.#.#.#.#.#.###.###.###.###.#.#########.#.#.#.#####.#####.#.#####.#.#.#.#.###.###.#.#.#####.###.#.#.#.### +#.#...#...#.......#...#.#.#...#.#.#.#...#.#.#.....#...#.#...#...#...#.#.......#.#...#...#.....#.........#.#.#.....#.......#...#.#.........#.# +#.#.#######.#########.#.#.#.#####.#.###.#.#.#####.###.#.#.#.#.#.###.#.#.#######.###.#####.#########.#####.#.#######.#####.#.#.#.#.#.###.###.# +#.#.#.....#.....#.....#.#.#.....#.#...#.#.#.....#.#...#...#.#.#.#...#.....#.....#...#...#.#...#.....#.....#...#.....#...#...#...#.....#.#...# +#.#.#.#.#.#####.#.#####.#.#####.#.#.#.#.#.#.###.###.#######.#.#.#.###.###.#.###.#.#.#.#.#.#.#.#.###.#######.#.#.#####.#.###########.#.#.#.#.# +#.#.#.#.................#.....#.#.#...#.#.#...#.....#.......#.#.#.#.....#.#.#...#.#.#.#...#.#.#.............#.#.#...#.#.........#.....#.#.#.# +#.#.#.#.#########.###.###.#####.#.#.#####.#.#####.###.#.#.###.###.#.#.#.###.#.###.###.#####.#.#.#.#############.###.#.#######.#.#.#.###.#.#.# +#.#.#.....#.....#.#.......#.....#.#.#.....#.#...#.....#...#...#...#.#.#.#...#...#.....#.....#.#...#...........#.#...#.#.....#.............#.# +#.#.###.#.###.###.###.#.###.#####.#.#.#######.#.#######.###.#.#.#####.#.#.#####.###########.#.#.###.#########.#.#.###.#.#.#.#.###.#.#.###.#.# +#.#.....#.......#...#...#.#.#.....#.#.#...#...#.......#...#.#.........#.#...#.#...#.........#.#.........#...#.#.#...#.#.#.#.#...#.#.#...#.#.# +#.#.###.###.###.#.#.###.#.#.###.#.#.#.#.#.#.#######.#.###.#.###.###.###.###.#.#.#.###.#######.#######.###.#.#.#.###.#.#.#.#.###.#.#.#.###.#.# +#.#...#.....#...#.#...#...#.#...#.#.#...#.#.......#.....#.#.#...#...#.#.........#...#.#.......#.....#.#...#.#.....#.#...#.#...#...#.#.....#.# +#.#.#.#.#####.#.#.###.#####.#.#####.#.###.#######.#.#.###.#.#.###.###.#########.###.#.#.#######.###.#.#.###.#####.#.#####.#.#######.#.#####.# +#.#.#.#.#.....#.....#.......#.#.....#...#...#...#.#.#.....#.#.#...#.....#.........#...#...#.....#.#.#...#.#...#.......#...#.................# +#.#.#.#.#####.###############.#.#######.#.#.###.#.#.###.###.#.#.#######.#.#.###########.###.#####.#.###.#.###.#########.#############.####### +#...#.#.....#...#.......#...#...#.......#.#...#.#.#...#.#.....#.#.......#.#.#.......#...#...#.....#...#.#...#.................#.....#.......# +###.#.#.###.#.#.#.#.###.###.#.#######.###.###.#.#.###.###.###.#.###.#.###.#.#.#.#.#.#.###.###.#######.#.#.#.#########.###.###.#.###.#.#####.# +#...#.#.#.#.#.#...#...#.....#.#.....#.#...#.#.#.#.#.#...#.#...#...#.......#...#...#.#.#.#.#.........#.#.#.#.#.......#.....#.#...#.#.#...#.#.# +#.#.#.#.#.#.#########.#####.#.#.###.###.###.#.#.#.#.###.#.#.#####.#.###########.###.#.#.#.###.#.#.#.#.#.###.#.#.###.###.#.#.#####.#.#.#.#.#.# +#.#.#.#...#.#.......#...#...#...#.#...#.#.......#...#.#.#...#.....#.#...#.....#.....#.#.#...#.#...#...#...#.#.#.#.#.#.#.#.#.......#.........# +#.###.###.#.#.#####.#.#.#.#######.#.#.#.###########.#.#.#####.#####.###.#.#.#####.###.#.###.###.#######.#.#.#.#.#.#.#.#.#.###.###.###.#.###.# +#.............#.#...#.#.#.#...#.....#.#...........#.#.#...........#...#...#.#...#.......#.#...#.........#.#...#.#.....#.#.#.................# +#.#####.#.###.#.#.###.#.#.#.#.#.###.#.###.#####.###.#.#########.#.###.#####.#.#.#######.#.###.###.#####.#.#.###.#######.#.#.###.###.#####.#.# +#.#.....#.....#...#...#.#.#.#.#...#.#...#.#...#.#...#.....#.......#.#...#...#.#...#...#.....#.#.......#.#.#...#.....#...#.#.#...#.......#.#.# +#.#.#####.#.###.#######.#.#.#####.#.###.#.#.#.#.#.###.#####.#######.###.#.###.###.#.#.#######.#######.###.###.#####.#.###.#.#.#####.###.#.#.# +#.............#.#...#.....#.....#.#.....#.#.#.#.#.#...#.....#.............#...#.#...#...#...#.......#...#.#...#...#.#.#.#...#.....#...#.#.#.# +###.#.###.###.#.#.#.#.###.#.#.#.#.#######.#.#.#.#.#.#.#.#####.#############.###.#######.#.#.#######.###.#.#.###.###.#.#.#########.#.###.#.### +#...#...#...#.....#.#...#.#.#.#...#.....#...#.#.....#.#...#.#.#...#.....#...#.......#.#...#.#.......#.....#...#...#...#.....#...#.#.....#...# +#.###.#.#.###.#####.###.#.###.#.#.#.###.#####.###########.#.#.#.###.#####.#.#.###.#.#.#####.#.#######.#######.###.#######.###.#.#.#.#######.# +#...#.#...#...#...#.#...#...#.#.#.#.#.#...#.#.#.....#.....#.#.#.#...#.....#.....#.#...#...#.#.#.....#.........#...........#...#...#.....#...# +###.#.###.#.#####.#.#.#####.#.###.#.#.###.#.#.#.###.#.#####.#.#.#.###.###.#######.###.#.#.#.#.#.###.#.###.#.#.#.#######.###.#######.###.#.### +#...#...#.#.#...#.#.#.#.#...#...#...#.....#...#.#.#...#.#...#...#.#.#.#.#...#.....#.#.#.#.#.#.#.#...#.#...#.#.#.#.......#...#.#.........#...# +#.#####.#.#.#.#.#.#.#.#.#.#####.#####.#####.###.#.#####.#.#.#.###.#.#.#.###.#.#####.#.#.#.#.#.#.###.#.#.###.#.#.#########.###.#.#.#.###.###.# +#.#.......#.#.#...#.#.#.#.#.....#...#.....#...#.#.........#...#...#.......#.#...#.......#.#...#.......#...#.#.#...........#...#.#.#...#.#...# +#.#.#####.#.#.#####.#.#.#.###.#.#.#######.###.#.#.#####.#######.#.#######.#.###.###############.#########.#.#.###.###########.#.#.#.#.#.#.#.# +#.#.#.......#...#...#.#.#.#...#...#...#...#...#.#.......#...#.#.#...#.....#.#...#...............#.#...#...#.#...#.#.........#...#.#.#...#...# +#.#.#.#######.#.#.###.#.#.#.###.###.#.#.#######.#.#######.#.#.#.#.#.###.###.#.###.#########.#####.#.#.#.#######.#.#.#.#####.#.###.#.#######.# +#.#.#...#.....#.......#...#...#.#...#...#.......#.........#...#...#...#.#...#...............#.....#.#...#...#.......#.#...#.#.#...#...#...#.# +#.#.###.#################.###.#.#.#######.#.#######.#################.#.#.###.#######.#####.#.###.#.#####.#.#.#########.#.#.###.###.###.#.#.# +#.#.#.#.....#.....#.....#.....#.#.....#.#.#.#.#.....#...#.........#...#.#.#...#...#.#.....#.#...#.#.......#.#.....#.....#.#.#...#...#...#...# +#.#.#.#####.#.###.#.###.#####.#######.#.#.#.#.#.#####.#.#.#######.#.###.#.#####.#.#.#.###.#.#.#.###########.#####.#.#####.#.#.###.###.#####.# +#.....#...#.......#...#.......#.......#...#.#.....#...#...#.......#.#...#.#.....#.#.#...#.#.#.#.......#...#...#.#...#...#.#...#.....#...#...# +#.#####.#.#######.#.###.#######.###########.#.#####.#######.#####.#.#####.#.#####.#.#.###.#.#.#######.#.#.#.#.#.#####.#.#.#########.###.#.#.# +#...#...#...#.....#.#...#.....#.....#.......#.#.#...#...#...#.....#.......#...#.#.#...#...#.#...#.....#.#...#...#.....#.#.....#.......#.....# +#####.#.###.#.#.###.#.#.#.###.#####.#.#######.#.#.#####.#.###.#############.#.#.#.#.###.#.#.###.#.#.#.#.#######.#.#####.#.###.#.###.#.#.#.#.# +#...#.#.....#.#.#...#.#.#.#.#.#.....#...........#.#.....#.#.#.#.............#.#.#.#...#.#.#.#...#.#.#.#.......#.#.#.........#.#.#.......#...# +#.#.#.#.#####.###.###.#.#.#.#.#.#####.###.###.#.#.#.###.#.#.#.###.#######.###.#.#.#####.#.#.###.#.#.#.#.#.#.#.#.###.#######.#.#.###.#######.# +#.#...#.......#...#...#.#...#.#.....#.#.#.....#...#...#...#.#...#.#...#.......#...#.....#.#...#.#.#.....#...#.#.....#.....#.#.#.........#...# +#.#####.#.###.#.###.#.#####.#.#####.#.#.#####.###.###.###.#.###.#.#.#.#.#######.###.#########.###.#####.#####.###########.#.#.#####.###.#.#.# +#.#...#.....#.#...#.#.#...#.#.....#.#.#.....#.#...#...#...#.#...#.#.#.#.......#.#...#.......#.#...#.#...#...#.#.........#...#.........#.#...# +#.#.#.#.#.###.###.#.#.#.#.#.#.###.#.#.#.###.#.#.###.###.###.#.#####.#.#.#.#.#.#.#.#.#.###.#.#.#.###.#.#.###.#.#.#######.#.#########.#.#.#.#.# +#.#.#...#.#.....#.#.....#...#...#.#.#...#...#...#...#...#...#.......#...#.#...#.#.#.#.#...#.#.#...#...#.....#.....#.....#...#.......#...#.#.# +#.#.###.#.#.#####.#############.#.#.#######.#####.#.#.###.#############.#.#.###.#.#.#.#.#.###.###.#.###.#.#.#######.#######.###.#.#.#######.# +#.#.#...#...#.....#.....#.....#.#.#...#...#.......#.#...#...#.........#...#.....#.#.#...#...#.....#.#...#.#.#.......#.....#...#.#.........#.# +#.#.#.###.###.#####.###.###.#.#.#####.#.#.#########.###.###.#.#####.#.#####.#####.#.#.#.###.#######.#####.#.#.#.#####.#######.###.#.###.#.#.# +#.#.#.#.#.#.#.#.......#.....#.#.....#...#.#.......#...#...#.#...#...#...#...#.....#.#...#.#...#...#.#...#.#.#.#.#...........#...#.#.....#...# +#.#.#.#.#.#.#.#.#####.###.#########.#####.#.###.###.#####.#.#.#.#.#######.###.#####.###.#.###.#.#.#.#.#.#.#.#.#.#.#######.#####.#.#.#######.# +#.#.........#.#.....#.#...#.......#.#.....#...#.....#.....#.....#.....#...#...#...#...#...#.#...#.#...#.#.#...#.#.....#...#.....#.#...#.#...# +#.#.#.###.#.#.###.###.#.###.###.###.#.#####.#########.#.#####.#######.#.###.###.#.#.#####.#.#####.#####.#.###.#.#####.#.###.#####.###.#.#.### +#...#.................#.#...#...#...#.....#.#.......#.#.#...#.....#...#.#.....#.#.#.....#.#.......#...#...#...#.#.....#.#...#...#.#.#.#.....# +#.#####.#####.#.###.#####.###.###.#.#####.###.#####.#.###.#.#####.#.#.#.#####.#.#######.#.###.#.#.#.#.#.#######.#######.#.###.#.#.#.#.####### +#...#.#.#...#.#...#.........#.....#.....#...#...#...#.....#...#.....#.#...#...#.......#.#.#...#.#...#...#.......#.......#.#...#.#...#.#.....# +###.#.#.#.#.#.###.###########.#.#####.#####.###.#.###########.#.#.#######.#.###.#.###.#.#.#.#.#########.#.#######.#####.#.###.#.#####.#.###.# +#...#.#...#.#...#.#.........#.#.#...#.#.....#...#.......#...#.#...#...#.........#...#.#...#.#.#...#...#.#.#...#.....#...#.....#...#...#...#.# +#.###.#####.###.###.###.#.#.#.#.#.#.#.#.#####.#########.#.#.#.#.###.#.#.#######.###.#######.###.#.#.#.#.#.#.#.#.###.#############.#.###.###.# +#.#...#.....#...#...#...#.#...#.#.#...#.......#.....#...#.#...#...#.#...#.....#...#.#.....#.....#.#.#...#.#.#.#.#...#.....#.....#.#.....#...# +#.###.#.###.#.###.#####.#.###.#.###############.###.#.###.#####.#.#.#######.#####.#.#.#.#.#######.#.###.#.#.###.#.###.###.#.###.#.#####.#.### +#.....#.#...#...#.#...#.#...#.#.#...........#.....#.#.#...#.....#...#.......#...#.....#.#.....#...#...#.#.#.#...#.....#.#.#.#.#.#.....#.#...# +#.#.#.#.###.###.#.#.#.#.###.###.#.###.###.#.#######.#.###.#.###.#####.###.###.#.#.#####.#####.#.#.###.#.#.#.#.#########.#.#.#.#.#####.###.#.# +#...#.#...#.....#.#.#.#.....#...#.......#.#.........#...#.#...#...#.....#.....#.....#...#.#.....#.#...#...#.#.....#.....#...#.#.....#...#.#.# +#####.###.#.#.###.#.#.#######.#########.#.#######.#####.#.###.#.#.#######.#######.#.#.###.#.#.#.#.#.#######.#####.#.###.#####.#.###.###.###.# +#.#.....#.#.#...#.#.#.........#.......#.#.#.....#.#...#.#...#...#.#.....#.#.......#...#.#.......#.#.#...#.......#...#...#.....#...#...#...#.# +#.#.#.###.#.###.#.#.###.#####.#.#.#####.#.#.###.###.#.#.#.#.#####.#.###.###.#####.###.#.#.#########.#.#.#.###.#######.#.#.###.###.#######.#.# +#...#.....#...#...#.....#...#.#.#.......#.#...#.#...#.....#.#.....#...#.....#...#.#.......#...#.....#.#.#...#.......#...#.#.#...#...#...#.#.# +#.###.###########.###.#.#.#.#.#.#########.###.#.#.#.#######.#.#######.#######.#.#.#########.#.#.#####.#.###.#.###.#.###.#.#.###.###.#.#.#.#.# +#.#.#.....#.......#.#.#.#.#.#.#.......#.....#.#...#...#.....#.#.....#.....#...#.#...........#.#...#...#...#.#...#.#.#...#.#.#...#.#...#.#...# +#.#.#####.#.#####.#.#.###.#.#######.#.#.#####.#####.#.###.###.#.###.###.#.#.###.#############.###.#######.#.#.#.#.#.#.###.#.#.###.#####.###.# +#...#...#.#...#.....#.....#.......#.........#.#.....#.#...#.#.#...#...#.#.....#.......#.....#...#...........#.#...#.#.#...#.#.#.......#.....# +###.#.#.#.###.#.###.#############.#.#######.#.#####.#.#.###.#.###.###.#.#########.###.#.#.#####.#.#####.#.###.#####.#.#.###.#.#.###.######### +#...#.#.#.#...#.#...#...........#.#.....#.......#...#...#...#...#.#.#.#...#.#.........#.#.......#...#...#.#.#.....#...#...#...#.#...#.....#.# +#####.#.#.#.###.#.###.###.#####.#.#####.#.#####.#.#.#####.#####.#.#.#.###.#.#.###########.###########.###.#.#####.#.#####.###.###.###.#.#.#.# +#...#.....#.#...#.....#...#...#.#.....#.#.#.....#.#.....#.....#...#...#.#.#.#...........#.................#...#...#.....#...#...#.....#.#.#.# +#.#.#.###.#.#.#.#######.###.#.#######.#.#.#.#####.#.#.#.#.###.#####.###.#.#.#########.#.#######.#.#####.#.###.#.#.#####.#.#.###.#######.#.#.# +#.#...#.....#.#.....#...#...#.........#.#...#.....#...#...#...........................#...#...#.#.#...#.....#.#.....#...#.#...#.....#...#.#.# +#.###.#.#.###.#.###.#.###.#.#########.#.#.###.#####.#####.#.#.#.###.#.#.###.#.#######.###.#.###.#.#.#.###.#.#.#.###.#.#.#.###.#####.#.###.#.# +#...#.#.....#.#...#.#.#...#.#...#...#.#...#.......#...#.#...#.#.#...#.#...#.#.....#...#...#.....#...#...#.....#.#...#.#.....#.....#.#.#.....# +#.#.#.###.#.#.#.#.#.###.###.#.#.#.#.#.###.#######.#.#.#.#.#.#.#.#.#######.#.#####.#.#.#.###.#####.#####.#.#####.#.#.#.#.#######.#.#.#.#.###.# +#.#.#.....#.#...#.#.....#.#.#.#...#.#...#...#.....#...#...#...#.#.......#.......#.#.#...#...#.........#.....#...#.#...#.#.....#.#.#.#.....#.# +#.#.#####.#.#.#.#.#######.#.#.#####.#####.#.#.#####.###.#.#.###.#######.#.#.#####.#.#.###.###########.#####.#.#.###.#.#.#.###.###.#.###.#.#.# +#.#.#...#.#.#.#.#...#.......#.....#.......#.#.#.....#...#.#.......#...#...#.#...........................#...#.#.....#...#...#.#...#.......#.# +###.#.#.#.#.#.#.###.###########.#.#####.#.#.#.#.#.#.###.#.#.#####.#.#.###.###.#####.###.#.#.###.#.#.###.#.###.#.###.#.#####.#.#.#######.###.# +#...#.#.....#.#...#.#...........#.#...#.....#.#.#.#...#.........................#.#.#...#...#...#.#.....#.#.....#...........#.#...#.#...#...# +#.#.#.###.#####.#.#.#.#######.###.#.#########.#.###.#.###.#.#####.#.#.###.#.#.#.#.#.#.#######.#########.#.###.###.#.#.#######.###.#.#.#.#.### +#.#.#.#...#.....#.#.#.#.....#.#...#...........#...#.........................#.#.#...#.#.#...#.#.............#...#.......#...#.....#...#.....# +#.###.#.#.#.#####.#.#.#####.#.#.###########.###.#.#.###.#.#.###.###.#.#.#.#.###.#.###.#.#.#.#.#.#.#.#.#####.###.###.#.#.#.#.#######.###.#.#.# +#S......#...#.....#.........#...............#...#.....#.......#.....#...#.......#.....#...#.....#...#.......#...........#.#.................# +############################################################################################################################################# diff --git a/2024/day16/input.txt.h b/2024/day16/input.txt.h new file mode 100644 index 0000000..42c8bc8 --- /dev/null +++ b/2024/day16/input.txt.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_2024_day16_input_txt_start __asm("_binary_2024_day16_input_txt_start"); +extern uint32_t _binary_2024_day16_input_txt_end __asm("_binary_2024_day16_input_txt_end"); +extern uint32_t _binary_2024_day16_input_txt_size __asm("_binary_2024_day16_input_txt_size"); + +#ifdef __cplusplus +} +#endif diff --git a/2024/day16/sample1.txt b/2024/day16/sample1.txt new file mode 100644 index 0000000..2c21676 --- /dev/null +++ b/2024/day16/sample1.txt @@ -0,0 +1,15 @@ +############### +#.......#....E# +#.#.###.#.###.# +#.....#.#...#.# +#.###.#####.#.# +#.#.#.......#.# +#.#.#####.###.# +#...........#.# +###.#.#####.#.# +#...#.....#.#.# +#.#.#.###.#.#.# +#.....#...#.#.# +#.###.#.#.#.#.# +#S..#.....#...# +############### diff --git a/2024/day16/sample1.txt.h b/2024/day16/sample1.txt.h new file mode 100644 index 0000000..94918e8 --- /dev/null +++ b/2024/day16/sample1.txt.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_2024_day16_sample1_txt_start __asm("_binary_2024_day16_sample1_txt_start"); +extern uint32_t _binary_2024_day16_sample1_txt_end __asm("_binary_2024_day16_sample1_txt_end"); +extern uint32_t _binary_2024_day16_sample1_txt_size __asm("_binary_2024_day16_sample1_txt_size"); + +#ifdef __cplusplus +} +#endif diff --git a/2024/day16/solution.c b/2024/day16/solution.c new file mode 100644 index 0000000..2f04949 --- /dev/null +++ b/2024/day16/solution.c @@ -0,0 +1,11 @@ +#include + +int64_t _2024_day16_part1(const char * input, int length) +{ + return -1; +} + +int64_t _2024_day16_part2(const char * input, int length) +{ + return -1; +} diff --git a/dijkstra.c b/dijkstra.c new file mode 100644 index 0000000..40be6d2 --- /dev/null +++ b/dijkstra.c @@ -0,0 +1,32 @@ +#include "cartesian.h" +#include "dijkstra.h" +#include "heap.h" +#include "memory.h" + +void dijkstra_cartesian(char * graph, + int stride, + int width, int height, + int source_x, int source_y, + int dest_x, int dest_y, + char wall) +{ + struct heap_entry queue[width * height / 2 + 1]; + int queue_length = 0; + + // distance from source + int dist[width * height]; + // initialize all distances to the maximum distance + memory_set_int(dist, 0x7fffffff, width * height); + // initialize the distance from the source to the source to zero + dist[source_y * width + source_x] = 0; + + + int prev[width * height]; + // initialize the all node paths to "unknown" + memory_set_int(prev, -1, width * height); + + // initialize the queue with "source" + heap_append_xy(queue, &queue_length, 0, source_x, source_y); + + //while queue_length > 0: +} diff --git a/dijkstra.h b/dijkstra.h new file mode 100644 index 0000000..e69de29 diff --git a/heap.c b/heap.c index f1214a7..d5c6d2e 100644 --- a/heap.c +++ b/heap.c @@ -1,4 +1,5 @@ #include "heap.h" +#include "memory.h" void heap_sift_up(struct heap_entry * e, int ix) { @@ -16,6 +17,31 @@ void heap_sift_up(struct heap_entry * e, int ix) } } +void heap_sift_down(struct heap_entry * e, int heap_length, int ix) +{ + while (true) { + int child_l = 2 * ix + 1; + int child_r = 2 * ix + 2; + if (child_l >= heap_length) + break; + + int child = child_l; + if (child_r < heap_length && e[child_l].key < e[child_r].key) { + child = child_r; + } + + if (e[ix].key < e[child].key) { + // swap child and ix + struct heap_entry tmp = e[child]; + e[child] = e[ix]; + e[ix] = tmp; + ix = child; + } else { + break; + } + } +} + void heap_append(struct heap_entry * e, int * heap_length, int key, int value) { int ix = *heap_length; @@ -25,6 +51,16 @@ void heap_append(struct heap_entry * e, int * heap_length, int key, int value) (*heap_length) += 1; } +void heap_append_xy(struct heap_entry * e, int * heap_length, int key, int x, int y) +{ + int ix = *heap_length; + e[ix].key = key; + e[ix].x = x; + e[ix].y = y; + heap_sift_up(e, ix); + (*heap_length) += 1; +} + int heap_find(struct heap_entry * e, int length, int ix, int key) { if (e[ix].key == key) @@ -47,3 +83,14 @@ int heap_find(struct heap_entry * e, int length, int ix, int key) return -1; } + +struct heap_entry heap_extract_max(struct heap_entry * e, int * heap_length) +{ + struct heap_entry entry = e[0]; + + (*heap_length)--; + memory_copy_u32(&e[1], *heap_length, &e[0]); + heap_sift_down(e, *heap_length, 0); + + return entry; +} diff --git a/heap.h b/heap.h index 21fb15a..9a22772 100644 --- a/heap.h +++ b/heap.h @@ -1,17 +1,28 @@ #pragma once +#include + #ifdef __cplusplus extern "C" { #endif struct heap_entry { int key; - int value; + union { + int value; + struct { + int16_t x; + int16_t y; + }; + }; }; void heap_sift_up(struct heap_entry * e, int ix); +void heap_sift_down(struct heap_entry * e, int heap_length, int ix); void heap_append(struct heap_entry * e, int * heap_length, int key, int value); +void heap_append_xy(struct heap_entry * e, int * heap_length, int key, int x, int y); int heap_find(struct heap_entry * e, int length, int ix, int key); +struct heap_entry heap_extract_max(struct heap_entry * e, int * heap_length); #ifdef __cplusplus } diff --git a/input_dreamcast.inc b/input_dreamcast.inc index 17b93d4..509e45f 100644 --- a/input_dreamcast.inc +++ b/input_dreamcast.inc @@ -41,6 +41,8 @@ #include "2024/day14/input.txt.h" #include "2024/day15/sample1.txt.h" #include "2024/day15/input.txt.h" +#include "2024/day16/sample1.txt.h" +#include "2024/day16/input.txt.h" static struct start_size sample[][2] = { { @@ -163,6 +165,12 @@ static struct start_size sample[][2] = { { ( char *)&_binary_2024_day15_sample1_txt_start, (uint32_t)&_binary_2024_day15_sample1_txt_size }, }, + { + { ( char *)&_binary_2024_day16_sample1_txt_start, + (uint32_t)&_binary_2024_day16_sample1_txt_size }, + { ( char *)&_binary_2024_day16_sample1_txt_start, + (uint32_t)&_binary_2024_day16_sample1_txt_size }, + }, }; static struct start_size input[] = { @@ -206,4 +214,6 @@ static struct start_size input[] = { (uint32_t)&_binary_2024_day14_input_txt_size }, { ( char *)&_binary_2024_day15_input_txt_start, (uint32_t)&_binary_2024_day15_input_txt_size }, + { ( char *)&_binary_2024_day16_input_txt_start, + (uint32_t)&_binary_2024_day16_input_txt_size }, }; diff --git a/linear_algebra.c b/linear_algebra.c index dd9d258..27251f3 100644 --- a/linear_algebra.c +++ b/linear_algebra.c @@ -1,7 +1,6 @@ #include "linear_algebra.h" #include "printf.h" -//#include double determinant_2x2(double a, double b, double c, double d) @@ -14,32 +13,6 @@ double determinant_2x2(double a, double b, return a * d - b * c; } -/* -5550.00 450000000444000.00 600000000222000.00 -81081081161.08 108108108148.11 - --3876.00 -460000000548084.00 -400000000524792.00 -118679050709.00 103199174542.00 - --6595.00 -470000000250610.00 -690000000567170.00 -71266110727.92 104624715779.71 - -4278.00 440000001045978.00 460000000280508.00 -102851800151.00 107526881786.00 -*/ - -union di { - double d; - int64_t i; -}; - -static int64_t raw_double(double n) -{ - union di di; - di.d = n; - return di.i; -} - struct double2 cramers_rule_2x2(double a1, double b1, double c1, double a2, double b2, double c2) { diff --git a/memory.c b/memory.c index fc68db0..ed5f3d3 100644 --- a/memory.c +++ b/memory.c @@ -22,3 +22,14 @@ void memory_copy_char(char * src, int length, char * dst) dst[i] = src[i]; } } + +void memory_copy_u32(void * _src, int length, void * _dst) +{ + // size given in bytes + uint32_t * src = _src; + uint32_t * dst = _dst; + + for (int i = 0; i < length; i++) { + dst[i] = src[i]; + } +} diff --git a/memory.h b/memory.h index f8c7995..78f9430 100644 --- a/memory.h +++ b/memory.h @@ -7,6 +7,7 @@ extern "C" { void memory_set_char(char * buf, char c, int length); void memory_set_int(int * buf, int c, int length); void memory_copy_char(char * src, int length, char * dst); +void memory_copy_u32(void * _src, int length, void * _dst); #ifdef __cplusplus } diff --git a/runner.inc b/runner.inc index a731291..3b5efcb 100644 --- a/runner.inc +++ b/runner.inc @@ -44,6 +44,8 @@ void _2024_day14_render(const struct font * font, const void * maple_ft0_data); int64_t _2024_day15_part1(const char * input, int length); int64_t _2024_day15_part2(const char * input, int length); +int64_t _2024_day16_part1(const char * input, int length); +int64_t _2024_day16_part2(const char * input, int length); struct day_funcs solution[] = { { @@ -146,4 +148,9 @@ struct day_funcs solution[] = { {_2024_day15_part1, _2024_day15_part2}, NULL, }, + { + 2024, 16, + {_2024_day16_part1, _2024_day16_part2}, + NULL, + }, }; diff --git a/solutions.mk b/solutions.mk index 9217c94..8aac665 100644 --- a/solutions.mk +++ b/solutions.mk @@ -63,4 +63,7 @@ DAY_OBJ = \ 2024/day14/solution.o \ 2024/day15/sample1.txt.o \ 2024/day15/input.txt.o \ - 2024/day15/solution.o + 2024/day15/solution.o \ + 2024/day16/sample1.txt.o \ + 2024/day16/input.txt.o \ + 2024/day16/solution.o diff --git a/test/run.sh b/test/run.sh new file mode 100644 index 0000000..15e34cf --- /dev/null +++ b/test/run.sh @@ -0,0 +1,19 @@ +#!bin/bash + +set -eux + +for i in test/test_*.c; do + name=${i%.c} + gcc -Og -g -gdwarf-5 \ + -std=c2x \ + -Wall -Werror -Wfatal-errors \ + -Wno-error=unused-variable \ + -I. \ + -o ${name} \ + ${name}.c \ + memory.c \ + dijkstra.c \ + heap.c + + ./${name} +done diff --git a/test/runner.h b/test/runner.h new file mode 100644 index 0000000..88630b1 --- /dev/null +++ b/test/runner.h @@ -0,0 +1,27 @@ +#pragma once + +typedef bool (*test_t)(const char ** scenario); + +#define ANSI_RED "\x1b[31m" +#define ANSI_GREEN "\x1b[32m" +#define ANSI_RESET "\x1b[0m" + +#define RUNNER(tests) \ + int main() \ + { \ + int fail_count = 0; \ + for (int i = 0; i < (sizeof (tests)) / (sizeof (test_t)); i++) { \ + const char * scenario = NULL; \ + bool result = tests[i](&scenario); \ + const char * result_s = result ? "ok" : ANSI_RED "fail" ANSI_RESET; \ + fail_count += !result; \ + fprintf(stderr, "%s: %s\n", scenario, result_s); \ + } \ + if (fail_count == 0) { \ + fprintf(stderr, ANSI_GREEN "failed tests: %d\n\n" ANSI_RESET, fail_count); \ + } else { \ + fprintf(stderr, ANSI_RED "failed tests: %d\n\n" ANSI_RESET, fail_count); \ + } \ + \ + return !(fail_count == 0); \ + } diff --git a/test/test_heap.c b/test/test_heap.c new file mode 100644 index 0000000..0c27387 --- /dev/null +++ b/test/test_heap.c @@ -0,0 +1,21 @@ +#include +#include + +#include "runner.h" + +#include "heap.h" + +static bool heap_test_0(const char ** scenario) +{ + *scenario = "heap_extract_max"; + + + + return false; +} + +test_t heap_tests[] = { + heap_test_0, +}; + +RUNNER(heap_tests) diff --git a/test/test_memory b/test/test_memory new file mode 100755 index 0000000000000000000000000000000000000000..1fbe435aff6220d670369a0cc484ce7537b2835f GIT binary patch literal 27840 zcmeHwdwf*Yz3*Ck_MVx%CQm{VUW0^}n8||>L4qa_aDqV~1PDbKhRNh{$g7hH1P&A= zVx5LmvFCU>S5BeTdOY{kqgLBm>#@>FR@14#5zHb9cgp~_|8WQk@PY7YsL+*rl!kQ5D>>IcbLL{jZ| z_`V=ArlF=s?YT)9#VyWJ=vMw~7%NAyIa46{&ny`Yx2d=sP*BTJljP1SxwA?x3dtd& zE2!g1F`;9j@+TfvfJUW4oEeLk>rry?(5?72)UjXpM!4b6vA0Iag_Xj1cv#ufP}^Gz zIf~2wYSF`7tL%+64n->d8mh3e!q%4UWu=9!4F#<&?cF^EJqybU%1S+59i9^50{K;h zgVN^u8`m@A02?5jN(g?PzFqLVxo8UmdT1Zj+jF8a-HMvWPSOTh6` z@E2{1F81l^L9|h23R)SXFtR~$bzcTw1>EKM?;nGoe7_uj;TZTIkD-V9cLk34LTR7Q za#=-%r09HQK3|~6?`v#n_qVp}38L8n#d|hFGDC}$Vx3mM(7(?$0 zHv~f=Ai)vXK_b3Je@iPPDH_@`c709t(q+C9Pl;ziv_9Wc8m*7i=9e;Gb=@i-GzObm zy28Ow-Ku4+9qqw7|Mph$tEsJ{UAf|ute0g(_mCSHdye^Q;%teWq84R^&g1U977V+^ zdYj%(6^M0rK6FB+ew@a_shj;<5B zJtq#oUhxlHC;2H?X-suF9fLPC67Wn6p5}rsuf*W>Tq4@p7`*nC@H#(e9@4ysmI_%T z9cpP42xkmlE%^eU7K0b_O<>1Q;}IB-z<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~dQ*4R1pAO>X +#include + +#include "runner.h" + +#include "memory.h" + +static bool memory_test_0(const char ** scenario) +{ + *scenario = "memory_copy_u32 ordering"; + + uint32_t l[] = {1, 2, 3, 4}; + + memory_copy_u32(&l[1], 3, &l[0]); + + return l[0] == 2 && l[1] == 3 && l[2] == 4; +} + +test_t memory_tests[] = { + memory_test_0, +}; + +RUNNER(memory_tests)