Giter Site home page Giter Site logo

advent-of-code-2022's Introduction

๐ŸŽ„ Advent of Code

Tests MIT License

Solutions to the Advent of Code challenges.

Year Days Completed Stars Collected
2022 2022 days completed 2022 stars collected

Setup

Requirements

For contributors, please use pnpm. Otherwise, feel free to use a package manager of your choice.

Installation

git clone [email protected]:dxnter/advent-of-code.git
cd advent-of-code
pnpm i

Note If you're using this project for your own solutions, the year folder(s) that contain previous solutions should be removed before use.

Usage

Scaffold the next day

pnpm scaffold

# output:
# SUCCESS  Puzzle files created
# +  advent-of-code/src/2022/07/input.txt
# +  advent-of-code/src/2022/07/day_07.ts
# +  advent-of-code/src/2022/07/day_07.spec.ts
# +  advent-of-code/src/2022/07/day_07.bench.ts
# ๐ŸŽ„ Run pnpm test 2022/07 to start the test runner

Scaffold a specific day

# example: `pnpm scaffold 2019/20`
pnpm scaffold <year>/<day>

# output:
# SUCCESS  Puzzle files created
# +  advent-of-code/src/2019/20/input.txt
# +  advent-of-code/src/2019/20/day_20.ts
# +  advent-of-code/src/2019/20/day_20.spec.ts
# +  advent-of-code/src/2019/20/day_20.bench.ts
# ๐ŸŽ„ Run pnpm test 2019/20 to start the test runner

Save the input

Once the file stubs are created, save the input for the puzzle you're solving in the input.txt file.

Checking solutions

Vitest is used as the test runner to validate the solutions in real-time with Watch mode. In order to benefit from this feature, the day_XX.spec.ts file should first be updated after the input is saved.

  1. Update the EXAMPLE variable to the example text displayed on AoC.
  2. Update the expected equal() value for the example in Part 1 from true to the expected value listed on AoC.

After the assertions have been updated in the test file, start the test runner with pnpm test and begin working on the solution in day_XX.ts. As you solve each part, the expected equal() value should be updated after a successful submission.

Commands

Check all of the solutions:

pnpm test

Check all of the solutions for an entire year:

pnpm test 2022

Check the solutions for a specific day:

pnpm test 2022/01

Benchmarking solutions

To compare the performance of your solutions, the benchmarking tool in Vitest is used. Vitest runs the solution multiple times to display different performance results.

Commands

Benchmark all of the solutions:

pnpm bench

Benchmark all of the solutions for an entire year:

pnpm bench 2022

Benchmark the solutions for a specific day:

pnpm bench 2022/01

advent-of-code-2022's People

Contributors

dxnter avatar

Watchers

 avatar

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.