antono
Trivial things about software development
10 posts
2 followers
Something about Cargo

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.

AOC: Puzzle 4: struct and impl

DISCLAIMER

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.

AOC: Puzzle 2.2 in rust

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.
Borrowing in Rust

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]...
AOC: Sharing code in Rust

After first puzzle in advent of code i found a function that can be reused:

I going to move this function to separate file and then somehow reuse in all my solutions. Quick googling leads to "Using Modules to Reuse and Organize Code" of The Rust Book.

what happens if you have too many functions? Rust has a module system that enables the reuse of code in an organized fashion.