Giter Site home page Giter Site logo

advent-of-code-rust's Introduction

Advent of Code

As a learning project, I will try to solve some of the AoC puzzles in Rust.

Disclaimer: I am Rust beginner, my code will probably be neither idiomatic, nor efficient.

Constraints:

  • Do not use of external crates. The goal is to learn Rust and to get familiar with the API of it's standard library. This means for example, no regex.
  • Use efficient algorithms and do the best to implement them efficiently in Rust.

Project structure

For the moment, the code is organized as follows, but this organization could change in the future. The crate has modules yearYYYY for each year with submodules dayDD for each day. A module util contains some commonly used tools. I will try to keep the same structure for each day :

const INPUT: &str = include_str!("../../data/yearYYYY/dayDD/input.txt");

pub fn solve() -> (u32, u32) {
    solve_input(INPUT)
}

pub fn solve_input(input: &str) -> (u32, u32) {
    (0, 0)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        let example = "";
        assert_eq!((0, 0), solve_input(example));
    }
}

The input is not read from a file but directly integrated in the binary.

The solve_input() function can be called passing either the small examples for testing or the real input.

Benchmarks

Measured by cargo bench on Intel(R) Core(TM) i7-1365U with RUSTFLAGS="-C target-cpu=native".

2023

Day Time (µs)
01 32
02 10
03 68
04 40
05 12
06 0

advent-of-code-rust's People

Contributors

sbalev 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.