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

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



Duration: 1:34:19
15 views
1


In this episode, we completed Advent of Code y2020 ex13 part 1 and did some good progress on part 2 as well.

In this exercise, we needed to figure out which bus to take by doing some interesting math.

We implemented a brute force solution for part 2 but it is not fast enough, so we'll need to figure out a more efficient approach to it.

Thanks to all our watchers for the great suggestions. We did learn a few interesting things:

- Use `filter_map()` with iterators (rather than a chain with a `filter()` and a `map()`): https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.filter_map
- Use `map()` to convert values inside `Result` types: https://doc.rust-lang.org/std/result/enum.Result.html#method.map
- `map()` works on Option too! https://doc.rust-lang.org/std/option/enum.Option.html#method.map
- `max_by_key()` is another convenient function that can be used to extract a max value from a `Vec` of complex types using some arbitrary max logic item by item (no comparison function needed): https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.max_by_key

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-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
code
advent of code
learning rust
live coding
pair programming
coding challenges
IRL