Skip to content

Commit

Permalink
y2023/ex11 updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lmammino committed Dec 11, 2023
1 parent 34dccbc commit 24a47c2
Showing 1 changed file with 110 additions and 5 deletions.
115 changes: 110 additions & 5 deletions y2023/ex11/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,120 @@
# Day 11: TODO: ADD TITLE HERE
# Day 11: Cosmic Expansion

[Check it out on adventofcode.com](https://adventofcode.com/2023/day/11)

## Part One

TODO: ADD DESCRIPTION HERE
You continue following signs for "Hot Springs" and eventually come across an [observatory](https://en.wikipedia.org/wiki/Observatory). The Elf within turns out to be a researcher studying cosmic expansion using the giant telescope here.

Your puzzle answer was `?`. (TODO: )
He doesn't know anything about the missing machine parts; he's only visiting for this research project. However, he confirms that the hot springs are the next-closest area likely to have people; he'll even take you straight there once he's done with today's observation analysis.

Maybe you can help him with the analysis to speed things up?

The researcher has collected a bunch of data and compiled the data into a single giant _image_ (your puzzle input). The image includes _empty space_ (`.`) and _galaxies_ (`#`). For example:

...#......
.......#..
#.........
..........
......#...
.#........
.........#
..........
.......#..
#...#.....


The researcher is trying to figure out the sum of the lengths of the _shortest path between every pair of galaxies_. However, there's a catch: the universe expanded in the time it took the light from those galaxies to reach the observatory.

Due to something involving gravitational effects, _only some space expands_. In fact, the result is that _any rows or columns that contain no galaxies_ should all actually be twice as big.

In the above example, three columns and two rows contain no galaxies:

v v v
...#......
.......#..
#.........
>..........<
......#...
.#........
.........#
>..........<
.......#..
#...#.....
^ ^ ^


These rows and columns need to be _twice as big_; the result of cosmic expansion therefore looks like this:

....#........
.........#...
#............
.............
.............
........#....
.#...........
............#
.............
.............
.........#...
#....#.......


Equipped with this expanded universe, the shortest path between every pair of galaxies can be found. It can help to assign every galaxy a unique number:

....1........
.........2...
3............
.............
.............
........4....
.5...........
............6
.............
.............
.........7...
8....9.......


In these 9 galaxies, there are _36 pairs_. Only count each pair once; order within the pair doesn't matter. For each pair, find any shortest path between the two galaxies using only steps that move up, down, left, or right exactly one `.` or `#` at a time. (The shortest path between two galaxies is allowed to pass through another galaxy.)

For example, here is one of the shortest paths between galaxies `5` and `9`:

....1........
.........2...
3............
.............
.............
........4....
.5...........
.##.........6
..##.........
...##........
....##...7...
8....9.......


This path has length `_9_` because it takes a minimum of _nine steps_ to get from galaxy `5` to galaxy `9` (the eight locations marked `#` plus the step onto galaxy `9` itself). Here are some other example shortest path lengths:

* Between galaxy `1` and galaxy `7`: 15
* Between galaxy `3` and galaxy `6`: 17
* Between galaxy `8` and galaxy `9`: 5

In this example, after expanding the universe, the sum of the shortest path between all 36 pairs of galaxies is `_374_`.

Expand the universe, then find the length of the shortest path between every pair of galaxies. _What is the sum of these lengths?_

Your puzzle answer was `9536038`.

## Part Two

TODO: ADD DESCRIPTION HERE

Your puzzle answer was `?`. (TODO: )
The galaxies are much _older_ (and thus much _farther apart_) than the researcher initially estimated.

Now, instead of the expansion you did before, make each empty row or column _one million times_ larger. That is, each empty row should be replaced with `1000000` empty rows, and each empty column should be replaced with `1000000` empty columns.

(In the example above, if each empty row or column were merely `10` times larger, the sum of the shortest paths between every pair of galaxies would be `_1030_`. If each empty row or column were merely `100` times larger, the sum of the shortest paths between every pair of galaxies would be `_8410_`. However, your universe will need to expand far beyond these values.)

Starting with the same initial image, expand the universe according to these new rules, then find the length of the shortest path between every pair of galaxies. _What is the sum of these lengths?_

Your puzzle answer was `447744640566`

0 comments on commit 24a47c2

Please sign in to comment.