-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,053 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "day08_haunted_wasteland" | ||
version = "0.1.0" | ||
edition = "2021" | ||
rust-version.workspace = true | ||
|
||
[dependencies] | ||
log.workspace = true | ||
env_logger.workspace = true | ||
nom.workspace = true | ||
num.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Very cheeky part 2. I basically winged it after seeing the example and | ||
thinking that "surely that's the least common multiple". I looked at the input | ||
and saw that the paths cycle (aka the end node cycles back to the start node) | ||
and then I just prayged that the cycles are "clean". It worked, but solution | ||
would definitely break on an input that's not this constrained. | ||
|
||
--- | ||
|
||
Being able to pass functions as arguments leads to some really nice code since | ||
you can code what an end node is through a: | ||
``` | ||
is_end_node: fn(&str) -> bool, | ||
``` | ||
And use that as a break condition for the traversal. | ||
|
||
--- | ||
|
||
Imported a new crate called `num` for the `lcm` implementation. I had not | ||
pulled in a new crate in a very long time. | ||
|
||
--- | ||
|
||
To have an iterator go back to the start when it reaches the end one can use | ||
the `cycle` function. I am surprised I have not used this before. It made it | ||
very easy to cycle through the instructions endlessly. |
Oops, something went wrong.