My solutions for Advent of Code 2022 wrapped in a resilient CLI and built using Maven and Java 17.
- Clone this repository to your local machine
- Install any missing dependencies:
- Create a new run configuration in IntelliJ IDEA:
- Set
JDK 17
as the JRE - Set
Main
as the main class
- Set
- Run the project π
Utils.java
contains some commonly used helper methods:
List<String> readFile(int day)
returns aList
containing the input for the provided day. Usage:List<String> day12Input = readFile(12);
String convertDayIntToString(int day)
returns a two-digitString
representation of the provided day. Usage:convertDayIntToString(02) == "02"; // true convertDayIntToString(12) == "12"; // true
void printSolutionMessage(int day, int part, String solution)
prints a solution message to standard output. Usage:printSolutionMessage(12, 1, "42"); // Solution (Day 12.1): 42
getValueOfCharacter(char character)
returns anint
value for a given character. Usage:getValueOfCharacter('a') == 1; getValueOfCharacter('B') == 28;
reverseString(String input)
returns a reversedString
of the given input. Usage:reverseString("Hello World!") == "!dlroW olleH"; // true
The models
directory contains classes that may come in handy:
FileNode
can be used to build a tree representing a file system. EachFileNode
has:List<FileNode> children
FileNode parent
(null
if it is the root)File data
File
can be used to represent a file in a file system. EachFile
has:String name
int size
(0
if it is a directory)
Monkey
can be used to represent a monkey playing keep away. EachMonkey
has:int id
Queue<Long> items
long itemsSeen
Map<String, Integer> operation
int throwConditionOperand
int trueThrowId
int falseThrowId