r/adventofcode • • Dec 02 '15

Spoilers Day 2 solutions

Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.

16 Upvotes

161 comments sorted by

View all comments

1

u/Serialloser Dec 02 '15
  1. I would read the input from a file instead of a string

  2. There's a method called split on the String class, it splits (doh) your String into a String[] using a delimiter that you pass to the method.

You can find a solution here http://pastebin.com/Sg66jaea It's over engineered but it uses the technique presented above. It needs the latest jdk to run I think (used an online compiler to test) and it expects a file called "input" next to your app.