Photo by Philipp Medicus (CC BY-NC 2.0)
Cargo is a tool that allows Rust packages to declare their various dependencies and ensure that you’ll always get a repeatable build.
This week i found something interesting about cargo.
First there is a well organized cargo book. Short and clear text. Cargo is easy to understand if you have ruby bundler or npm background.
Each time i dig into some interesting topic while solving Advent Of Code puzzles. This time it was rust structs and method implementation for structs.
For tracking guard shift (see puzzle details) i introduced ShiftTimeline structure:
The idea was to keep minutes between the guard was sleeping in vector.
Input is the same as for 2.1. This time I must find ids that differs by one letter in the same position:
The IDs abcde and axcye are close, but they differ by two characters (the second and fourth). However, the IDs fghij and fguij differ by exactly one character, the third (h and u). Those must be the correct boxes.
Doing puzzle #2 of advent of code challenge in Rust. The puzzle is pretty simple. Input looks like this:
The task is:
...count the number that have an ID containing exactly two of any letter and then separately count those with exactly three of any letter. You can multiply those two counts together to get [an answer]...
After first puzzle in advent of code i found a function that can be reused:
what happens if you have too many functions? Rust has a module system that enables the reuse of code in an organized fashion.