AlexAegis / advent-of-code

My solutions for Advent of Code

Home Page:https://adventofcode.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

typescript ci rust ci python ci

Codacy Badge Maintainability Test Coverage codecov Coverage Status

Last commit on GitHub code style: prettier

This is a multi-language repository, for easy usage, all of them share the same root level. You need to individually set up each language you wish to use.

Usage

The repository does not contain task inputs as my own inputs are located in a private repository. If you wish to use this repository with your own inputs provide them in the following folder structure:

resources
├── 2015
│   ├── 01
│   │   └── input.txt
│   ├── 02
│   │   └── input.txt
│   │  ...
│   └── 25
│       └── input.txt
│   ...
└── 2023
    ├── 01
    │   ├── example.1.txt
    │   ├── example.2.txt
    │   └── input.txt
    │  ...
    └── 25
        └── input.txt

Cloning

Reference for myself, cloning with my private inputs

git clone --recurse-submodules -j8 git@github.com:AlexAegis/advent-of-code.git

Why and how

2023 TypeScript Progress 2022 TypeScript Progress 2021 TypeScript Progress 2020 TypeScript Progress 2019 TypeScript Progress 2018 TypeScript Progress 2017 TypeScript Progress 2016 TypeScript Progress 2015 TypeScript Progress

Setup TypeScript workspace

Install latest stable node and pnpm

pnpm install

Running individual TypeScript solutions

# Navigate to the solution
cd solutions/typescript/2023/01
pnpm p1
pnpm p2

Debugging TypeScript solutions using VS Code

Open the solutions file, then run the [TS] Current File debug profile.

Testing all TypeScript solutions

pnpm test

Testing individual TypeScript solutions

# Navigate to the solution
cd solutions/typescript/2023/01
pnpm test

Benchmarking individual TypeScript solutions

# Navigate to the solution
cd solutions/typescript/2023/01
pnpm bench

Linting all TypeScript solutions

pnpm lint

Linting individual TypeScript solutions

# Navigate to the solution
cd solutions/typescript/2023/01
pnpm lint:tsc
pnpm lint:es
pnpm lint:format

2023 Rust Progress 2022 Rust Progress 2021 Rust Progress 2020 Rust Progress 2019 Rust Progress 2018 Rust Progress 2017 Rust Progress 2016 Rust Progress 2015 Rust Progress

2023 Python Progress 2022 Python Progress 2021 Python Progress 2020 Python Progress 2019 Python Progress 2018 Python Progress 2017 Python Progress 2016 Python Progress 2015 Python Progress

Setup Python workspace

Install latest stable python and pipenv

pipenv install
pipenv shell

Working with private files

If you wish to replicate the same input setup that I have so that it's compliant with Advent of Code's rules, you should not keep your inputs in a publicly hosted repository. I think the best solution to this is to keep them in a private submodule, keeping your inputs private, but your solutions public and keeping your CI happy and operational.

Why?

See the "Can I copy/redistribute part of Advent of Code?" section at https://adventofcode.com/2023/about

How?

  1. Collect your input files into a new "advent-of-code-inputs" repository

  2. Get a fresh clone of your repository!

  3. Install git-filter-repo

    You will completely rewrite your repository's history, so first educate yourself on how git-filter-repo works. (The tool you might find for this first is the BFG Repo cleaner, however git-filter-repo is much more capable and can clean out huge repositories in just milliseconds.)

  4. Clean out the repository: git filter-repo --invert-paths --path-glob '*.txt' --path inputs

    This is just an example command, add more globs or paths if needed

  5. Verify that apart from the unwanted files everything is in order. Check older commits too!

    Maybe in previous years you stored these files differently, and/or you refactored them at some point!

  6. Add back your inputs as a git submodule:

    git submodule add git@github.com:AlexAegis/advent-of-code-inputs.git resources
    git commit -m 'added inputs submodule'
  7. Adjust your CI so that it checks out submodules too.

    If you're using GitHub Actions and actions/checkout:

    - name: checkout
      uses: actions/checkout@v4
      with:
        fetch-depth: 1
        submodules: true
  8. Verify if everything works locally

  9. If everything looks right, re-add your remote and force push the changes. (Since you started with a fresh clone, your old can be used to restore it if anything goes wrong at any point)

    git remote add origin git@github.com:AlexAegis/advent-of-code.git
    git push --force
  10. Clean out remaining branches by either force pushing them too or just removing them.

Disclaimer

Advent of Code is made by Eric Wastl.