Advent of code in Rust - solving year 2020 exercise 14 - Part 1 (Twitch Live 2021-06-28)

Subscribers:
953
Published on ● Video Link: https://www.youtube.com/watch?v=thcdDUKE4Lw



Duration: 1:28:26
24 views
2


In this episode, we completed Advent of Code y2020 ex14 part 1 (on which we started in the previous session ➡️ https://www.youtube.com/watch?v=NcKODh5riqk).

This exercise is basically a simulation of a simple calculator that can allocate memory and apply some sort of bit-masking algorithm to change the values in memory. We needed to run a given script as input and see what was the final configuration of the memory (output).

We started with a very simple solution that wasn't particularly performant but it did work. Then we figure out how to re-implement the same solution by using AND and OR bit operations. That was quite a performance improvement.

We took the opportunity to use criterion (https://docs.rs/criterion/0.3.4/criterion/) to run benchmarks in a very effective way. It's a great library so check it out if you haven't used it already.

We also had a bunch of questions on idiomatic Rust and one of the guides that were suggested was the official Rust naming convention guide (https://rust-lang.github.io/api-guidelines/naming.html#c-conv) which also explains what all the various `into_x()`, `as_x()` and `to_x()` generally means.

We didn't start part 2 because we spent the last portion of the stream discussing a PR we received on the previous exercise (https://github.com/lmammino/rust-advent/pull/6) which was suggesting the usage of the iterator method `partition()` (https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.partition).

We ended up not merging that PR because of significant performance differences with our original implementation, although we did really like to learn about the `partition()` method.

Feel free to send us more PRs if you want to recommend us to use a different approach! We are here to learn and we'd be happy to receive more and more suggestions :)

For all the source code check out the official GitHub repo: https://github.com/lmammino/rust-advent

For seeing the next episodes live check out our Twitch channel: https://twitch.tv/loige




Other Videos By Luciano Mammino (loige)


2021-09-27Advent of code in Rust - solving year 2020 exercise 19 p1 (Twitch Live 2021-09-27)
2021-09-20Advent of code in Rust - solving year 2020 exercise 18 p2 (Twitch Live 2021-09-20)
2021-09-14Advent of code in Rust - solving year 2020 exercise 18 p1 (Twitch Live 2021-09-13)
2021-09-06Advent of code in Rust - solving year 2020 exercise 17 p2 (Twitch Live 2021-09-06)
2021-08-30Advent of code in Rust - solving year 2020 exercise 17 p1 (Twitch Live 2021-08-30)
2021-08-24Advent of code in Rust - reviewing year 2020 exercise 16 - Part 2 + 17 p1 (Twitch Live 2021-08-23)
2021-08-17Advent of code in Rust - solving year 2020 exercise 16 - Part 2 (Twitch Live 2021-08-16)
2021-08-10Advent of code in Rust - solving year 2020 exercise 16 - Part 1 (Twitch Live 2021-08-09)
2021-07-12Advent of code in Rust - solving year 2020 exercise 15 - Part 1 & Part 2 (Twitch Live 2021-07-12)
2021-07-05Advent of code in Rust - solving year 2020 exercise 14 - Part 2 (Twitch Live 2021-07-05)
2021-06-28Advent of code in Rust - solving year 2020 exercise 14 - Part 1 (Twitch Live 2021-06-28)
2021-06-27Working on Rust crate "gmaps-static" (Google Static Maps API URL builder) - Twitch live 2021-06-27
2021-06-21Advent of code in Rust - solving year 2020 exercise 13 - Part 2 (Twitch Live 2021-06-21)
2021-06-14Advent of code in Rust - solving year 2020 exercise 13 - Part 1 (Twitch Live 2021-06-14)
2021-06-07Advent of code in Rust - solving year 2020 exercise 12 - Part 2 (Twitch Live 2021-06-07)
2021-05-31Advent of code in Rust - solving year 2020 exercise 12 - Part 1 (Twitch Live 2021-05-31)
2021-05-24Advent of code in Rust - solving year 2020 exercise 11 - Part 2 (Twitch Live 2021-05-24)
2021-05-19Advent of code in Rust - solving year 2020 exercise 11 (Twitch Live 2021-05-18)
2020-04-26Middy.js contribution graph



Tags:
rust
rustlang
live coding
advent of code
coding in rust
learning rust
pair programming
mob programming
IRL
in real life
learning in public