This is my showcase for (eventually) solving all the problems on adventofcode.com using Rust.
All the examples can be tested to work by using
cargo test example
This will show you that my code works for the same example listed on adventofcode.com for each puzzle.
I encourage you to try and solve the problems yourself, you will have a lot of fun. But if you are looking for quick solutions to your own inputs, see the next segment.
Since every user on adventofcode.com gets his own unique input to puzzles, mine are placed in the inputs directory for each year. If you want to get the answers to your own input, simply replace the file contents for the specified puzzle.
You can then run tests with:
cd y2021
cargo test day07
This will pass if you used my input files, but will fail if you replaced them. That's good! You can see the correct answer by looking at the output.
For example, assuming you replaced the contents of y2021/inputs/day07.txt, you will see something like this output:
thread 'day07::tests::task_1' panicked at 'assertion failed: `(left == right)`
left: `123456`,
right: `356958`', src\day07.rs:84:9
This means that my expected output (for puzzle 2021, day 7, part 1) was 356958
but your correct answer is 123456
!
- I've used some small part of code from TheAlgorithms/Rust
- I've learned Rust mainly from YouTubers such as Let's get Rusty | Derek Banas | Code to the Moon | No Boilerplate > These have been extremely helpful even as I improved in my abilities and I highly recommend you check out their channels!