A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Viinyard/adventofcode-template below:

Viinyard/adventofcode-template: Java template project to get started with Advent of Code with automatic generation of code skeleton for each solution

Clic on Use this template and clone the repository.

Then, build the project with the following command:

If you want to customize the project, and change the group id for example, you can change group id in the pom.xml file:

  <groupId>dev.vinyard.adventofcode</groupId>

If you do this you also need to change the package name in the BluePrinter environment.xml file to keep it working:

  <property key="PACKAGE">dev/vinyard/adventofcode</property>

All the generated files will be created in the new package.

Setting up the environment

To get the Advent of Cope scrapper plugin to work, you need to set up your session id :

You can set your session id in your environment variables:

How to get my session id
  1. Go to the Advent of Code website.
  2. Connect to your account.
  3. Open the developer tools of your browser.
  4. Go to the Application tab.
  5. In the Cookies section, you will find a cookie named session.
  6. Copy the value of the cookie.
Show instruction for Linux or macOS
  export AOC_SESSION_ID=your_session_id
Show instruction for Windows

You have to go to the environment variables and add a new one with the name AOC_SESSION_ID and the value your_session_id.

Or you can set it in the BluePrinter environment.xml file:

  <property key="SESSION_ID">your_session_id</property>

Caution

Be careful not to share your session id with anyone, don't commit it in your repository.

Configure your repository
  1. Allow github action to create pull requests on your repository:

  2. Add your session_id in your secrets:

  3. Create a Personal Access Token (PAT) for the workflow:

That's it, you are ready to generate your solutions with Github Actions. Solutions will be generated in a brand new branch and a pull request will be created.

To generate the next solution of the year for Advent of Code, run the following command:

  mvn blueprinter:blueprint@next-solution 

To generate a specific solution for Advent of Code, run the following command:

  mvn blueprinter:blueprint@solution -Dyear=2023 -Dday=1 -Dpart=1

Important

To generate a new pull request with the solution, you need to have your GitHub environment set up

  1. On your repository, go to the Actions tab.
  2. Go to the All workflows section.

You will see 3 workflows:

Once you have generated the solution, you can implement the code in the generated files.

  1. You can find the antlr4 grammar in the src/main/antlr4 directory.
  2. You can find the solution in the src/main/java directory
  3. Go to the src/test/java directory to initialize the first test result.
  4. The first test from the test.txt is not automatically generated, you need to copy it from the Advent of Code website and paste it in the second argument of the testSolution method in the test file.
  5. You can run the tests, and begin to implement the solution until all tests pass.
  6. Once the first test passes, you can try to paste the result of the second test as your puzzle answer in the advent of code website.
  7. Don't forget to paste it in the expected result of the second test in the test file.
  8. Now you can refactor your code to make it more efficient, and run the tests to check if everything is still working.
  9. Push your changes to your repository, and the workflow will generate the README.md file with the result of the tests and benchmarks.

Important

Automated generation of the README.md is disabled by default, because it erase the actual content of the README.md file. You can enable it by uncomment the on: section in the .github/workflows/build.yml file.

on: 
   pull_request:
   push:
     branches:
       - master

Tip

You can find a lot of examples of resolved solutions in my repository adventofcode.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4