r/adventofcode • u/desrtfx • Dec 19 '15
Help [Day 19 (Part 2)][Java] - Part 1 works, part 2 results in an infinite loop
Edit: Solved thanks to /u/Dataforce's suggestion.
Tried my solution, a solution from one of the users in my subreddit (both in Java), tried 2 Python solutions from the Day 19 Solutions megathread and all produce the same output: Day 19 part 2 runs in an infinite loop.
Tried sorting the transformations by various criteria -> exactly the same result.
Did anybody else encounter the same?
Here is my not working solution in Java
And finally the working solution in Java
4
Upvotes
2
u/kd7uiy Dec 19 '15
I doubt Day 19 is really an infinite loop, it just takes a really long time if you don't order things correctly.
2
u/inorix Dec 19 '15 edited Dec 19 '15
Indeed your input doesn't produce a result with my code at least.
Edit: https://www.reddit.com/r/adventofcode/comments/3xflz8/day_19_solutions/cy4cu5b
This finds your result though.
1
u/thudbang Dec 21 '15
I had the same input. I totally over-engineered it, but I was able to get a solution with zero randomness by writing a parser combinator with memoization. This took a long time and I wouldn't recommend it, but it was a learning voyage I guess.