Advent of code in Rust - solving day 7/2021 and day 8/2021 part 1 (Twitch Live 2022-03-7)

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



Duration: 1:04:15
19 views
2


In this episode, we completed day 7 of Advent of Code y2021 using Rust! We also started day 8 of the same year and got as far as completing part 1 and doing some interesting benchmark tests to measure hashsets vs btreesets performance with a small set of numbers.

The first challenge wasn't too hard if solved with maths. The first part of day 7 required us to calculate the median, while part 2 was easily solved with average and the gauss formula to sum the first n numbers.
An interesting thing we learned is that with a Vec of integers we can use the function `select_nth_unstable` (https://doc.rust-lang.org/beta/std/primitive.slice.html#method.select_nth_unstable) to extract the median without needing sorting. This resulted significantly faster (about 25%) than sorting the vec (even with unstable).

Day 8 is much more challenging and it will require us probably a dedicated episode to go through part 2.

In this exercise we'll need to go to deduct mapping between cables and a led display that shows digits by looking at a series of measurement and proceeding by exclusion.

The first part was very easy because we just needed to count the occurrence of strings of a certain length in the input, but part 2 is where the magic will happen so stay tuned for that one!

If you have any suggestion, we'd love to hear it, so please leave a comment or a create a PR!

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)


2022-07-04๐Ÿฆ€ Rust vs ๐Ÿ Python: Advent of code in Rust - solving day 17/2021 (Twitch Live 2022-07-04)
2022-06-01Finding a lost song with Node.js & async iterators - Node.js Global Summit
2022-05-30๐Ÿฆ€ Rust vs ๐Ÿ Python: Advent of code in Rust - solving day 16/2021 (Twitch Live 2022-05-30)
2022-05-16๐Ÿฆ€ Rust vs ๐Ÿ Python: Advent of code in Rust - solving day 15/2021 (Twitch Live 2022-05-16)
2022-05-09๐Ÿฆ€ Rust vs ๐Ÿ Python: Advent of code in Rust - solving day 14/2021 (Twitch Live 2022-05-09)
2022-04-25๐Ÿฆ€ Rust vs ๐Ÿ Python: Advent of code in Rust - solving day 13/2021 (Twitch Live 2022-04-25)
2022-04-11๐Ÿฆ€ Rust vs ๐Ÿ Python: Advent of code in Rust - solving day 12/2021 (Twitch Live 2022-04-11)
2022-04-04๐Ÿฆ€ Rust vs ๐Ÿ Python: Advent of code in Rust - solving day 11/2021 (Twitch Live 2022-04-04)
2022-03-28Advent of code in Rust - solving day 10/2021 (Twitch Live 2022-03-28) with Python comparison! ๐Ÿ
2022-03-21Advent of code in Rust - solving day 8/2021 part 2 and day 9/2021 (Twitch Live 2022-03-21)
2022-03-07Advent of code in Rust - solving day 7/2021 and day 8/2021 part 1 (Twitch Live 2022-03-7)
2022-02-21Advent of code in Rust SPECIAL - solving day 6/2021 on a RASPBERRY PICO (Twitch Live 2022-02-21)
2022-02-14Advent of code in Rust - solving day 6/2021 (Twitch Live 2022-02-14)
2022-02-07Advent of code in Rust - solving day 5/2021 (Twitch Live 2022-02-07)
2022-01-31Advent of code in Rust - solving day 4/2021 (Twitch Live 2022-01-31)
2022-01-24Advent of code in Rust - solving day 3/2021 (Twitch Live 2022-01-24)
2022-01-17Advent of code in Rust - solving day 2/2021 (Twitch Live 2022-01-17)
2022-01-10Advent of code in Rust - solving day 25/2020 & day 1/2021 (Twitch Live 2022-01-10)
2021-12-13Advent of code in Rust - solving year 2020 exercise 24 part 1 (Twitch Live 2021-12-13)
2021-12-07Advent of code in Rust - solving year 2020 exercise 23 part 2 (Twitch Live 2021-12-06)
2021-11-29Advent of code in Rust - solving year 2020 exercise 23 part 1 (Twitch Live 2021-11-29)



Tags:
rust
rustlang
advent of code
aoc
adventofcode
game of life
learning rust
live coding
pair programming
mob programming
live stream
twitch
educational
iterator
fromStr
traits
coding challenge
problem solving
irl
in real life
day2
year 2021
aoc2021
advent of code 2021