Skip to content

shnako/advent-of-code-2022

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advent of Code 2022 🎄

I've only used Python in my last job, so I'll use AoC 2022 as a refresher in Java.

I tried to make the code as clean and easy to read as possible, and I've also provided a short explanation to most solutions so that they're easier to understand.

Day Puzzle Solution Results Input Text
01 Calorie Counting Day 01 solution Day 01 test Day 01 input Day 01 puzzle
02 Rock Paper Scissors Day 02 solution Day 02 test Day 02 input Day 02 puzzle
03 Rucksack Reorganization Day 03 solution Day 03 test Day 03 input Day 03 puzzle
04 Camp Cleanup Day 04 solution Day 04 test Day 04 input Day 04 puzzle
05 Supply Stacks Day 05 solution Day 05 test Day 05 input Day 05 puzzle
06 Tuning Trouble Day 06 solution Day 06 test Day 06 input Day 06 puzzle
07 No Space Left On Device Day 07 solution Day 07 test Day 07 input Day 07 puzzle
08 Treetop Tree House Day 08 solution Day 08 test Day 08 input Day 08 puzzle
09 Rope Bridge Day 09 solution Day 09 test Day 09 input Day 09 puzzle
10 Cathode-Ray Tube Day 10 solution Day 10 test Day 10 input Day 10 puzzle
11 Monkey in the Middle Day 11 solution Day 11 test Day 11 input Day 11 puzzle
12 Hill Climbing Algorithm Day 12 solution Day 12 test Day 12 input Day 12 puzzle
13 Distress Signal Day 13 solution Day 13 test Day 13 input Day 13 puzzle
14 Regolith Reservoir Day 14 solution Day 14 test Day 14 input Day 14 puzzle
15 Beacon Exclusion Zone Day 15 solution Day 15 test Day 15 input Day 15 puzzle
16 Proboscidea Volcanium Day 16 solution Day 16 test Day 16 input Day 16 puzzle
17 Pyroclastic Flow Day 17 solution Day 17 test Day 17 input Day 17 puzzle
18 Boiling Boulders Day 18 solution Day 18 test Day 18 input Day 18 puzzle
21 Monkey Math Day 21 solution Day 21 test Day 21 input Day 21 puzzle
22 Monkey Map Day 22 solution Day 22 test Day 22 input Day 22 puzzle
23 Unstable Diffusion Day 23 solution Day 23 test Day 23 input Day 23 puzzle
24 Blizzard Basin Day 24 solution Day 24 test Day 24 input Day 24 puzzle
25 Full of Hot Air Day 25 solution Day 25 test Day 25 input Day 25 puzzle

Structure

The corresponding files for each solution are grouped within a dayXX package. Each package contains:

  • Solution.java: my implementation of the solution to the puzzle
  • puzzle.txt: a dump of the puzzle text from the website, with the source link at the top
  • input.txt: the puzzle input I received

Each solution extends the SolutionBase interface and must implement the runPart1 and runPart2 methods which return the result as a string.

Each test implements the SolutionBaseTest interface and must specify the expected results in the test assertions.

Running

All solutions via tests

You can run all the tests using gradle:

./gradlew test

or if you're using Windows:

gradlew.bat test

Individual solutions via main

You can also take advantage of the functionality implemented in Main.java to run the puzzles individually:

./gradlew run --args='<day> <part>'

or if you're using Windows:

gradlew.bat run --args="<day> <part>"

replacing <day> with the puzzle's day number and <part> with either 1 or 2, or 0 to run both parts.

Running without the arguments will prompt you to enter them.