A project to get you started solving Advent of Code challenge in Java.
Each day should extend the parent Day
class, and initialise Day.currentDay
with an instance of the day using a static initializer block. Day
has a main method which will execute the code for the current day based on input in src/main/resources/day[number].txt
Running your child class will load the puzzle input and print the results of part1()
and part2()
to stdout
.
- Each day's puzzle will have an input consisting of one or more lines of plain text.
- Each day's puzzle will have two "parts" requiring separate implementations, but using the same input.
- Puzzle solutions will be a single line of text.
- Each puzzle description will provide at least one example input/output.
The shell for day 1 is already there. These are the steps to add day 2, etc. For day 1 you can start by writing the test cases once the puzzle posts.
- Create
aoc.day02.Day02.java extends Day
- Create a static initialization block in
Day02.java
to set your newDay
child class:static {currentDay = new Day02();}
- Create
Day02Test.java
and use the sample input/output from https://adventofcode.com/2019/day/2 to write tests (they will initially fail). - Implement
Day02.part1()
until the tests pass (Test Driven Development!). You can run./gradlew --continuous check
to have the tests run every time you save your code. - When the example input passes, get your unique puzzle input from https://adventofcode.com/2019/day/2/input and save it as
src/main/resources/day02.txt
- Run
./gradlew clean build install && ./build/install/advent-of-code/bin/advent-of-code 2
to get your output.- Notice the day number ("2") is passed to the start script as an argument.
- Check your solution on https://adventofcode.com!
- Add new tests for part 2 to
Day02Test.java
using the sample input/output from https://adventofcode.com/2019/day/2 - Implement
Day02.part2()
until the tests pass. - When the example input passes, run
./gradlew clean build install && ./build/install/advent-of-code/bin/advent-of-code 2 2
to get your output.- Notice the second argument to the script is the part number. It defaults to 1, so now you have to pass it as 2.
- Check your solution on https://adventofcode.com!