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

2

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

Definitely an option, but I'm not yet fit enough with lambdas. I keep trying, but the old, lengthy way keeps pushing it's way forward in my brain...

Brain.exe has entered energy saving mode. No new skills will be absorbed in that mode. It's only possible to exit energy saving mode after Vacation1_0.exe has completed it's run ;)

2

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

It helps if you use IntelliJ. It keeps telling you to use lambda's. I would suggest trying to use a forEach with a lambda in situations where you'd normally use a for-loop. Like when you print a list:

List<String> list = Arrays.asList("Apple", "Orange", "StrawBerry");
list.forEach(s -> System.out.println(s));

Or even shorter with a method reference:

list.forEach(System.out::println);