Giter VIP home page Giter VIP logo

adventofcode-2022's Introduction

Advent of Code 2022

My solutions for the Advent Of Code 2022 puzzles written in Rust.

Can be found both on GitHub and my Gitea.

This code in organized with :

  • A top-level crate to run tests and benchmarks
  • Sub-level crates for each day (dayXX)
  • A common crate for the common methods

Summary :

Stars obtained :

⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛
⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛
⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛
⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛
⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛

Run times (on a Dell Precision 3571 with an i7-12700H) :

Day 01 Day 02 Day 03 Day 04 Day 05
Part 1 27.3 µs 18.8 µs 28.6 µs 45.4 µs 35.8 µs
Part 2 30.6 µs 29.0 µs 26.6 µs 45.9 µs 35.6 µs
Day 06 Day 07 Day 08 Day 09 Day 10
Part 1
Part 2
Day 11 Day 12 Day 13 Day 14 Day 15
Part 1
Part 2
Day 16 Day 17 Day 18 Day 19 Day 20
Part 1
Part 2
Day 21 Day 22 Day 23 Day 24 Day 25
Part 1
Part 2

In order to check those benchmarks, run cargo bench on the root crate.

Sub-level day crates

The sublevel day crates are both executable and libraries. The main logic is always implemented in lib.rs but a main method exists in main.rs to read the data file and show the answers. So, you can go to any day and run cargo run to see the day's answers.

dayXX
|- Cargo.toml
`- src/
   |- main.rs
   `- lib.rs

Tests

Every sub-level day crate contains tests for the examples given on that day. You can run cargo test in those day crates to see that examples are successfully processed.

The common crate

The common crate defines methods and macros used by multiple day crates :

  • read_data : reads the data from the file into a String
  • tests! : a macro designed to write quick unit tests based on an input and the expected output

Top-level tests and benchmarks

The metrics provided above are computed using cargo bench in the top-level crate. That crate also contains tests to check that the results of the computation are still valid for all days and parts.

License

This entire code is licensed under ACSL, with the criterion crates licensed under MIT.

adventofcode-2022's People

Contributors

lugrim avatar lymkwi 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.