Coder Social home page Coder Social logo

aoc22's Introduction

AdventOfCodeTemplate

A sample template for Rust solutions to any one year of Advent of Code.

Adapted by Finlay Wojtan from a previous template by Simon Castle (which was itself adapted from a previous template by Chris Paterson).

How to Use

Get setup

  1. Set up your Rust environment
  2. Clone this template (git clone https://github.com/CastleQuirm/AdventOfCodeTemplate.git)
  3. Test you can run the code, using the Day 00 example.
    • In the terminal, go to the directory you've cloned the repo into (the directory containing this README.md file)
    • Run cargo run 0
      • This should show some build output (the first time this is run), followed by

      Day 0

      Part 1: 5971

      Part 2: 1155077

      0.024ms (exact time may vary) ----------

    • Run cargo test 00
      • This should show some build output (the first time this is run), followed by

      running 3 tests

      test day00::tests::check_day00_both_case1 ... ok

      test day00::tests::check_day00_part1_case1 ... ok

      test day00::tests::check_day00_part2_case1 ... ok

      test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 75 filtered out; finished in 0.00s

  4. Optionally, in order to use the benchmarking functionality, please install valgrind e.g. sudo apt install valgrind.

Solving puzzles

Start implementing solutions! - Copy and paste your input for the day (e.g. 2020 Day 1's input) into the matching numbered file in the inputs directory - Implement the solution in the matching numbered dayXX.rs file in src - Run the program using cargo run (with the day number to run just that one day, rather than all of 1-25). Add --release to perform a release build for a faster run! - (Optional) Add examples from the puzzle statement into tests in the same file. - Run the tests using cargo test (with the day number to run just the appropriate tests, rather than the tests for every day).

Benchmarking

Pass --bench when running (e.g. cargo run 0 --bench) to benchmark your code using iai. For the purposes of benchmarking, each solution is split into parse_input, part_one and part_two.

Other things I might at some point add...

  • benchmarking using criterion
  • cargo flamegraph CPU profiles
  • heap allocation info using valgrind/massif
  • better parsing of bench output

aoc22's People

Contributors

fwojtan avatar simoncastle avatar castlequirm 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.