Giter Club home page Giter Club logo

advent-of-code-2023's Introduction

Advent of Code 2023

GitHub License Build Status

This is my implementation of the Advent of Code programming challenges in Rust.

Results

Day Part 1 Part 2
Day 1
Day 2
Day 3
Day 4
Day 5
Day 6
Day 7
Day 8

Benchmarks

The following benchmarks were created on a Macbook Pro with an M2 Pro processor:

Day Part 1 Part 2
Day 1 24.2µs 120.8µs
Day 2 40.9µs 40.8µs
Day 3 260.7µs 116.3µs
Day 4 85.2µs 104.7µs
Day 5 19.5µs 55.2µs
Day 6 0.21µs 0.25µs
Day 7 3.87ms 5.12ms
Day 8 619.5µs 796.6µs

Project Structure

This project is organized as a single crate with a different binary for each day and some common helpers to reduce the boilerplate.

  • data - Holds data that gets run against the code
  • data/examples - Holds the examples that are provided with the challenges
  • data/examples/xx/part-x.txt - Since each day has 2 parts, each part is located in a separate file inside a directory for that day. See Example Format.
  • data/inputs/xx.txt - The input files for each day. See Downloading Input Files.
  • src/lib.rs - Contains some helper code to reduce boilerplate such as the solution! macro
  • src/main.rs - Contains a simple binary to download the input files. See Downloading Input Files.
  • src/bin/xx.rs - The solution files for each day

Downloading Input Files

Since input files are unique to every user, you need to supply your session token to be able to download the inputs for your account. This can be done through the AOC_SESSION_TOKEN environment variable.

With your session token in your environment, you can invoke the downloader with:

$ cargo run

Running A Specific Day's Solution

To run the solution code for a specific day, all you need to do is supply the correct binary name to cargo:

$ cargo run --bin 01

Running Example Tests

All the solution files include tests for the provided examples in the prompt. See Example Format for more details. To run the test suite on all the solutions, use:

$ cargo test

And to run the tests for a particular solution, use:

$ cargo test --bin 01

Running Benchmarks

All the example tests also include benchmarks to measure the performance of the solutions. You can run the benchmark suite on all the solutions like this:

$ cargo bench

Or run them for a specific day like this:

$ cargo bench --bin 01

Example Format

To remove the need for solution files to include tests for the examples, examples for each day are stored in a special format which includes the expected solution, and can easily be parsed by the runner helpers. Example files look like this:

<expected solution>
---
<example input>

For example, Day 1's example for part 1 looks like this:

142
---
1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet

advent-of-code-2023's People

Contributors

wowkster avatar

Stargazers

 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.