Skip to content

hsaikia/Advent-of-Code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advent of Code

This repo contains my solutions to Advent of Code problems in Rust. It also includes a helper library that I've developed over time, consisting of data structures and functions that have proven useful in solving past problems.

2024 2023

How to run

You need to have rustc (and cargo) installed. Instructions here.

Then for any particular year YYYY and day DD we need to run this command from the root directory

cargo run --release --bin <YYYY_DD> <input_file>

Alternatively, if an input.txt file exists in a directory src/bin/<YYYY_DD> along with the main.rs file, it will be used automatically. In that case, we just need to run

cargo run --release --bin <YYYY_DD>

For example for binary 2022_01 say we have a sample_input.txt file with the following contents

1000
2000
3000

4000

5000
6000

7000
8000
9000

10000

Then we run

cargo run --release --bin 2022_01 <full path to sample_input.txt>

which outputs the answers for both parts

Part #1 Answer 24000
Time elapsed in Part #1 is: 75µs

Part #2 Answer 41000
Time elapsed in Part #2 is: 5.042µs

Testing

Unit tests are included for some problems using the sample IO. To run tests

cargo test

To test a specific binary only

cargo test --bin 2023_01

Documentation

To generate the docs for this package, run cargo doc --open

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages