-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Day 9: Rope Bridge #11
Comments
Example board is 6 wide, 5 high. But... there are values in |
Movement rules:
|
I need to model the state of the board, then loop through each move in turn applying it to the head. After each move is applied to the head I can run code which decides if the tail should be updated or not - and logs the co-ordinates that the tail has visited so I can count them at the end. |
I got 14 against the example. I stopped counting the starting point as somewhere visited by the tail and got the expected answer 13. Then I tried against CORRECTION: That's because I modified |
Output against
|
Part 2:
|
Got it to work against the larger example AND got the right result for my input - 2541. I modified the original script without creating a backup, so now my solution to part 1 lives on in version control: advent-of-code-2022-in-rust/day_09/src/main.rs Lines 1 to 98 in b46f205
Here's my part 2 solution: advent-of-code-2022-in-rust/day_09/src/main.rs Lines 1 to 108 in 58aae1d
|
https://adventofcode.com/2022/day/9
Wow this one is a bit complicated. I'm modelling a rope with a head and tail. The head moves around - the tail follows.
Moves example:
H
is rope head,T
is rope tail,s
is the starting position:etc.
For the example the answer is 13.
The text was updated successfully, but these errors were encountered: