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

3

u/nutrecht Lead Software Engineer / EU / 20+ YXP Dec 07 '15 edited Dec 07 '15

Day 7

This one was actually pretty challenging. My "pretty smart" solution that worked for the sample input didn't work at all for the long input. So the solution was a recursive solver.

Edit: I also moved all my solutions to separate classes and moved everything into a public github repo.

1

u/TheHorribleTruth Kind of meh Dec 08 '15 edited Dec 08 '15

Day 07

It's ugly (once again), and doesn't use a proper flood-fill algorithm as I intended. I could get away with visiting the nodes multiple times.

Also, c/p from another comment:

This task description is somewhat lacking.. For instance I just disregarded that the range is supposed to be 16 bits, and just used ints. Seemed to work just as well.

1

u/nutrecht Lead Software Engineer / EU / 20+ YXP Dec 09 '15

Tip: to get a 16-bits number you can just and the integer with 0xFFFF. You only 'need' to do that for the NOT operation. Funny enough the way the sequences are constructed you don't seem to need to do it, even though if they hadn't done it you would've ended up with the wrong results.

You can check out my solution: it works with a lot less code.