Advent on Code - event for software engineers that happens every year.
This event is a set of new puzzles every day in December.
This project is designed to remove setup boilerplate and start coding in feature rich environment immediately.
- Automatic task input downloads.
- OneLiner unit tests.
To start:
Create solution file.
public record Day1Puzzle1() implements Solution {
@Override
public Object solve(String input) {
return "Implement Me";
}
Run
make download
Run
make solve
See: IDE: VS Code section
git checkout -b solution
Create .env file in root directory and add following line:
AOC_TOKEN="<YOUR_COOKIE>"
After that run
make download
You have downloaded task input to: src/resources/puzzle/2024_01_1.txt
Create empty .env file. Create src/resources/puzzle/2024_01_1.txt Copy and paste your first puzzle input in that file.
make test
ExampleTest.testTutorial:19->check:1->SolutionBaseTest.check:33 expected: <11> but was: <Not Implemented>
First puzzle is in src/main/java/dev/aoc/starter/solution/year2024/Day1Puzzle1.java
make solve
and submit your solution
- Create a java class in dev.aoc.starter.solution
- Java class full name must contain year, day and level separated by non-digits.
- Example: dev.aoc.starter.solution.year2024.Day1Level1.java
- Example: dev.aoc.starter.solution.Y24D1T1.java
- Extend class from dev.aoc.starter.solution.Solution
- Implement solver
Find you cookie for AoC in your browser. Put you cookie in .env file under AOC_TOKEN=""
$ make download
It will download puzzle input to ./src/resources/puzzle/{YYYY}_{dd}_{id}.txt
Sure. Create empty .env file. Create a file ./src/resources/puzzle/{YYYY}_{dd}_{n}.txt and copy/paste your input there.
$ make uberjar
$ java -jar ./target/starter-0.0.1-SNAPSHOT.jar --help
./mvnw spring-boot:run -Dspring-boot.run.arguments="solve -y 2024 -d 01 -p 1"
java -jar ./target/starter-0.0.1-SNAPSHOT.jar solve -y 2024 -d 01 -p 1
make solve
./mvnw spring-boot:run -Dspring-boot.run.arguments="solve"
java -jar ./target/starter-0.0.1-SNAPSHOT.jar solve
make submit
./mvnw spring-boot:run -Dspring-boot.run.arguments="solve -s"
java -jar ./target/starter-0.0.1-SNAPSHOT.jar solve -s
- Create test inputs in src/test/resources/puzzle directory
- Create a test class in src/test/java/dev/aoc/starter/solution/
- Example: src/test/java/dev/aoc/starter/solution/ExampleTest.java
- Use
@SpringBootTest
@ActiveProfiles("test")
@ContextConfiguration(classes = {TestConfiguration.class})
- Extend from src/test/java/dev/aoc/starter/solution/SolutionBaseTest.java
- use helper functions defined in base class to make tests as oneliner.
@Test
void testSolutionScenario() {
check(of(2024, 15, 2, "suffix"), "1982");
}
This will test solution for puzzle:
Year = 2024, day = 15, level = 2.
Input file src/test/resources/puzzle/2024_15_2_suffix.txt
Expected result "1982"
$ make format
$ make test
Delete relevant plugin sections in pom.xml
npm install
Install prettier extension
{
"[java]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"editor.formatOnSave": true,
"prettier.requireConfig": false
}
See: How to Mirror
If you want to mirror a repository in another location, including getting updates from the original, you can clone a mirror and periodically push the changes.
Open Terminal.
Create a bare mirrored clone of the repository.
git clone --mirror https://github.com/EXAMPLE-USER/REPOSITORY-TO-MIRROR.git
Set the push location to your mirror.
cd REPOSITORY-TO-MIRROR
git remote set-url --push origin https://github.com/EXAMPLE-USER/MIRRORED
As with a bare clone, a mirrored clone includes all remote branches and tags, but all local references will be overwritten each time you fetch, so it will always be the same as the original repository. Setting the URL for pushes simplifies pushing to your mirror.
To update your mirror, fetch updates and push.
git fetch -p origin
git push --mirror
NOTE
$ git push - this will delete any custom code you had in the mirrored repo.
You can disable 1 to 1 mirroring using
$ git config remote.origin.mirror false
$ git fetch -p origin
$ git push -u origin main