Advent of Code 2022 - Day 9

This is a thread to discuss Day 9

https://adventofcode.com/2022/day/9

REMEMBER!
It is VERY important NOT to write any public spoilers :slight_smile:
ALWAYS keep spoiler stuff hidden inside one of these

Summary

This text will be hidden

which you can obtain by clicking on the gear icon

image

Done part 1 but part 2 might require quite a few changes! (it did!)

Part 1


Part 2 at last!


Part 1



I had to google how to move a number towards 0. My original idea didn't work, but when I did it like this, it somehow worked. I don't understand how, but it does.

Oh, and since I could, here's my visualization
2022 day 9 part 1 visual

green = tail
red = head

(I had to make it really small to make it all fit on the stage)

Part 2

It took me a while to realize that the movement was the same for each know, with the knot above it being the head.

project

edit: wow, we used the same colors for the head and tail...

what does the update points block do

Move the tail and add it's position to a list

I am going to refactor part 1 to turn the head and tail into a single 2 item list of sprites.