Skip to content
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

Why day 9 part 2 works #1

Open
JBeet opened this issue Dec 9, 2024 · 0 comments
Open

Why day 9 part 2 works #1

JBeet opened this issue Dec 9, 2024 · 0 comments

Comments

@JBeet
Copy link

JBeet commented Dec 9, 2024

I'm pretty sure your day 9 part 2 works because you do not join consecutive empty blocks together.

Let's take the test input, where block 8 should not be moved:
00...111...2...333.44.5555.6666.777.888899

In your data it would look like this:

00 | ... | 111 | ... | 2 | ... | 333 | . | 44 | . | 5555 | . | 6666 | . | 777 | . | 8888 | 99

After moving block 9 and block 7 it is

00 | 99 | . | 111 | 777 | 2 | ... | 333 | . | 44 | . | 5555 | . | 6666 | . | ... | . | 8888 | ..

Now there are 5 empty spaces, and block 8 would fit, but for your algorithm it looks like (1+3+1) empty spaces.

@JBeet JBeet changed the title Why part 9 works Why day 9 part 2 works Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant