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

Show parent comment

4

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

Ah, beat me by 10 minutes :) Day 10 was very easy IMO.

Here's mine. Straightforward index processing, didn't do anything special or optimizing. I'm sure there's going to be nice Java 8 solutions by /u/nutrecht and /u/Philboyd_Studge again :)

Now off to work..

Edit: your solution and mine are practically the same :)

1

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

Just was able to beat you because I didn't write unit tests ;) (I did do some quick test runs with the sample data, though).

Yes, the problem was fairly easy this time. Still, looking forward to see some polished, Java 8 magic solutions - calling /u/nutrecht and /u/Philboyd_Studge ;)

2

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

Sorry to disappoint. There's very little Java 8 in there: I haven't quite figured out how to do the fold-left needed.

2

u/Philboyd_Studge Dec 11 '15

Day 10 - mine was pretty straightforward also Switching to Integers and specifying the capacity of the list got it down to less than 1 second for part 2. I wasted a ton of time first making a FSM version, then trying recursion which caused a stack overflow, then iterative with strings which took too long to run.

I still have to finish day 9 - got way into over-engineering it.

1

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

Ah. Took me a few seconds to figure out you were splitting the char[] into a list of integers :)