Skip to content

brianschubert/Advent-Of-Rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advent of Rust

Build Status

My solutions to the Advent of Code puzzles, written in Rust.

As with my previous attempt at solving the AoC 2017 puzzles in Kotlin, these solutions represent my first endeavors with the Rust programming language.

Some Language Details

Solutions for the 2015 and 2016 events were initially compiled with Rust v1.23.0 (2015 edition) and have since been migrated to support Rust v1.36.0 (2018 edition). All solutions that were written for the 2018 event were compiled with Rust >= v1.36.0 (2018 edition) from the start.

Rust written for the AoC 2018 event is formatted with the standard rust-fmt tool. Code from the 2015 and 2016 events follows a personal style that predates rust-fmt.

Running a Solution

Solutions may be run using cargo with the following format:

$ cargo run year day [input-file]

For example, to run the solution for the puzzle from Day 2 of 2016, you can write:

$ cargo run 2016 2

If you would like to use your own input file, simply include the path to it as the third argument:

$ cargo run 2016 2 ~/my/input/file

It is worth noting that a handful of solutions take advantage of patterns that exist in my puzzle inputs, but which may not be present in all valid inputs. As such, my solutions might be liable to panic when given input different from the ones that they were designed against.

If all goes well, you should be met with an output that resembles the following:

Solving 2016 day 02 ... OK
Input: ./resources/y2016/day02.txt

Part 1: `99332` [0.000457333s]
Part 2: `DD483` [0.000369839s]

Setup, Parsing: 0.000747620s
Total Elapsed: 0.001574792s

Running Tests

Nearly all modules in this repository come equipped with unit tests.

Most solutions are packaged with unit tests for both the examples in the puzzle descriptions as well as for the actual solutions for my inputs.

If you would like to run these tests, you can use the cargo test command, which is documentation in the Cargo Book

As an example, to run all the tests associated with the puzzle from Day 2 of 2016, you can write:

$ cargo test 2016::day02

A handful of the included unit tests take a few minutes to run. Cargo will ignore these tests by default, but, if you would like to run them, pass the --ignored flag with the test binary's arguments (after a --):

$ cargo test 2016::day02 -- --ignored

(Don't forget some popcorn!)

Copyright & License

Copyright © 2018, 2019 Brian Schubert - available under MIT License.

About

Solutions for the Advent of Code 2015, 2016, and 2018 challenges in Rust

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages