r/javahelp • Out of Coffee error - System halted • Dec 02 '15

[META] Daily coding challenges for the Advent

For those who haven't yet seen it on other subreddits or on Facebook:

Advent of Code

Has daily coding challenges during the Advent season up to the 25th of December.

Each daily challenge is split in two parts of which the second one is only unlocked after successful completion of the first part.

The challenges are relatively small and fun to make.

Have fun coding!


EDIT

In order to prevent spoilers (that would reduce the fun for the others), please do not post code directly here in the thread, post the code on pastebin, gist, github, bitbucket, or the code hoster of your choice and link here only.


Edit 2: Post stickied for the duration of the Advent of Code to make it easier to find.

22 Upvotes

137 comments sorted by

View all comments

1

u/Philboyd_Studge Dec 19 '15 edited Dec 19 '15

Well, Day 19 part 1 wasn't hard. Part two, on the other hand, is a bear.

eh, was overthinking it. Don't over think it!!! Day 19

1

u/TheHorribleTruth Kind of meh Dec 19 '15

Thanks for the hint. I've just looked at it: it screams "LALR"/"LL" parser if multiple "production steps" would be run in task 2, but given the other problems that's probably overkill or rather: not needed at all.

1

u/desrtfx Out of Coffee error - System halted Dec 19 '15 edited Dec 19 '15

My solution is practically the same as yours, but on part 2 it runs into an infinite loop.

Tried my input with your solution -> same result :( bummer

Edit: Tried my input with two of the Python solutions - exactly same result - infinite loop on the first one/error on the second one :(

For those who are interested My INPUT

Edit 2: Read in a solution that sorting by length (longest transform to shortest) could help -> again same result

Edit 3: /u/Dataforce found the trick :) shuffling the list of transforms and restarting eventually solves the problem.

Working code

1

u/Philboyd_Studge Dec 19 '15

I'm guessing that I got lucky!

1

u/desrtfx Out of Coffee error - System halted Dec 19 '15

Definitely.

In my thread in /r/adventofcode others have also commented that their inputs didn't produce an output unless the transforms were shuffled.