Giter Club home page Giter Club logo

advent-of-code's Introduction

Advent of Code

Welcome to my repo for all Advent of Codes advent-of-code.
I have decided to -- from now on -- redo all AoC's done so far (and all future AoC's) in Java, so I made this repository to host them all.

Project/day setup

  • macOS Monterey 12.0.1
  • Maven 4.0.0 project with Java 17 LTS
  • ./Makefile to automatically create each new day from template files for THE CURRENT YEAR
  • util package for whatever
  • Day's (dev/janetschel/calendar/dayx/) are set up like this:
    • input.txt for the input → will be fetched automatically and NOT created by the Makefile
    • Puzzle.java for the actual solution each day
    • README.md for solve times (if year >= 2020, before that, I didn't do AoC)

All you need to do if you want to create a new day to start coding is:
  • In the terminal navigate to ./
  • Type following: make new year=<year>

This will generate the needed file structure for day x in this year's AoC

Utils

My utils will have some handy functions/classes to work with the input.

Dynamic execution of code

Since this repo contains code to all AoC's and I needed the way to execute them all together AND independently of each other, there is a handy class (Calendar.java) which -- via reflection -- searches and executes all classes belonging to the specified year/day.

It works as follows: (Calendar.java)

@ExecutedDays(day = ALL_DAYS)
public class Calendar {
    private static final String CURRENT_YEAR = "2021";

    // ...
}

Change the annotation @ExecutedDays according to this regex:

^ALL_DAYS|DAY_(?:0[1-9]|1[0-9]|2[0-5])$

And it will run the specified day (or all days) from the corresponding year.
It searches all relevant packages and executes top level classes in these packages.

If you want to exclude specific classes (like DTOs, ...) from executing place them in a folder either called:

  • modles or
  • refactored.

A possible folder structure could look like this:

advent-of-code/
├── src.main.java.dev.janetschel
│   ├── calendar
│   │   └── year2021/
│   │       └── day01/                // <-- all this structure is generated by 'make new'
│   │           ├── refactored/       // <-- classes in this folder (or models) are not executed
│   │           ├── Puzzle.java
│   │           ├── README.md
│   │           └── input.txt         // <-- created by fetch utils
│   └── utils/
├── Makefile 
└── template/                        // <-- change the files in this folder if you wish to modify your blueprint

When running/executing days, the output will be in following format:

Solutions for Advent of Code 2021
Day 01:
01.1: 1527 (-> took ~6.7ms [6699.458µs])
01.2: 1575 (-> took ~1.2ms [1208.291µs])

Fetch utils

The fetch utils will automatically fetch the input from the current day and create an input.txt file.
If the file has been created once, it is be cached and only read from -- not updated -- so the API from won't be spammed.

You need to do no setup for this -- except for your session-key. More information can be found here.

advent-of-code's People

Watchers

 avatar  avatar  avatar

Forkers

byrdman32

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.