Skip to content

Commit

Permalink
Add solution for 2023 day11
Browse files Browse the repository at this point in the history
  • Loading branch information
Daedrus committed Dec 11, 2023
1 parent 1bec8fe commit 7705f7d
Show file tree
Hide file tree
Showing 6 changed files with 388 additions and 0 deletions.
11 changes: 11 additions & 0 deletions 2023/day11_cosmic_expansion/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "day11_cosmic_expansion"
version = "0.1.0"
edition = "2021"
rust-version.workspace = true

[dependencies]
log.workspace = true
env_logger.workspace = true
ndarray.workspace = true
itertools.workspace = true
19 changes: 19 additions & 0 deletions 2023/day11_cosmic_expansion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
My first thought reading this was [Floyd-Warshall](https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm).
But since this is a discrete matrix then the distances between the galaxies can
be computed using a simple [Taxicab/Manhattan distance](https://en.wikipedia.org/wiki/Taxicab_geometry).
Now, the crucial piece of information that makes this work is that "the
shortest path between two galaxies is allowed to pass through another galaxy".
Without this, the taxicab distance _does not_ work. I did not read that part
initially so I had dismissed this solution, instead looking into how to
implement [A\*](https://en.wikipedia.org/wiki/A*_search_algorithm).

I remember seeing on reddit the expression "Advent of reading comprehension"
and this is the perfect example of that. The constraint did eventually register
with me so I went back to taxicab but I had spent quite a bit of time to reach
that point.

---

Regarding the implementation itself, there's nothing special, this was just
another one of those mathy problems and I lucked out on part 2 being easy
purely because I didn't choose to go for a graph implementation in part 1. Meh.
Loading

0 comments on commit 7705f7d

Please sign in to comment.