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 04 '15 edited Dec 04 '15

I'm ready.... 2.5 hours away...

edit: ok, HOW THE HELL DID PEOPLE SOLVE THIS IN 2 MINUTES. I've used MD5 before, and I still had to do a little googling to get it working. took me 30 minutes to get both.

here's mine can't believe I forgot about string.startsWith

REFACTORED DAY 4

1

u/TheHorribleTruth Kind of meh Dec 04 '15

can't believe I forgot about string.startsWith

Well.. there's some excellent tutorials about Strings that you can find in the wiki.. :P

1

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

Your code is pretty inefficient. Mine finds the second one in aobut 3.5 seconds on my laptop. Key difference is that I don't bother making a String out of the hash and that your for loop to check if the string begins with a zero is pretty inefficient.

1

u/Philboyd_Studge Dec 04 '15 edited Dec 04 '15

yes, that code was just to get the answers as fast as I could. Here's a refactored, much more efficient one:

http://pastebin.com/JK5wYFfy