Giter VIP home page Giter VIP logo

advent-of-code-2015's Introduction

๐ŸŽ„ Advent of Code 2015

Solutions for Advent of Code in Rust.

2015 Results

Day Part 1 Part 2
Day 1 โญ โญ
Day 2 โญ โญ
Day 3 โญ โญ
Day 4 โญ โญ
Day 5 โญ โญ
Day 6 โญ โญ
Day 7 โญ โญ

Usage

Scaffolding files and downloading puzzle input

cargo scaffold 1 --download   # Create scaffolding for day 1 and download puzzle input
cargo scaffold 1              # Create scaffolding for day 1
cargo download 1              # Download puzzle input for day 1
cargo read 1                  # Read puzzle description for day 1

Testing

cargo test
cargo test --bin 01
cargo test --bin 01 part_one

Debugging

  1. Install the rust-analyzer and CodeLLDB extensions
  2. Set breakpoints in your code
  3. Click Debug next to the unit test or the main function
  4. The debugger will halt your program at the specific line and allow you to inspect the local stack

Running and submitting

cargo solve 1              # Run day 1 solution against real puzzle inputs
cargo solve 1 2            # Run day 1, part 2 solution against real puzzle inputs
cargo solve 1 2 --release  # Run day 1, part 2 solution against real puzzle inputs with an optimized build
cargo all                  # Run all solutions sequentially
cargo all --release        # Run all solutions sequentially with optimized build
cargo solve 1 --submit 2   # Submit day 1, part 2 solution

Benchmarking

cargo time 1              # Run day 1 10-10K times (depending on execution time) and print the average runtime
cargo time --all          # Print the average runtime for all days
cargo solve 1 --dhat      # Analyze day 1 heap allocations with DHAT (https://valgrind.org/docs/manual/dh-manual.html)
cargo time 1 --store      # Add day 1 timings to the readme
cargo time --all --store  # Add all timings to the readme

The --dhat command will output some basic stats to the command-line and generate a dhat-heap.json report in the repo root directory. You can pass the report a tool like dh-view to view a detailed breakdown of heap allocations.

Linting and formatting

cargo fmt
cargo clippy

Session cookie for AOC CLI

  1. Copy the session ๐Ÿช from the AOC website (you'll find it under Cookies in the Application or Storage tab)
  2. Create a $HOME/.adventofcode.session file and paste the ๐Ÿช there
  3. Create an AOC_SESSION repo secret and paste the ๐Ÿช there as well (Settings -> Secrets -> New repository secret)
  4. When the ๐Ÿช expires, repeat steps 1-3, replacing the old value with the new one

Common pitfalls

  • Whitespace in input: Make sure the input file has no leading or trailing whitespace, including no newline at the end of the file.
  • Integer overflows: This template uses 32-bit integers by default because it is generally faster - for example when packed in large arrays or structs - than using 64-bit integers everywhere. For some problems, solutions for real input might exceed 32-bit integer space. While this is checked and panics in debug mode, integers wrap in release mode, leading to wrong output when running your solution.

advent-of-code-2015's People

Contributors

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