Advent of code in Rust - solving year 2020 exercise 18 p2 (Twitch Live 2021-09-20)
In this episode, we completed the second part of Advent of Code y2020 ex18!
In this episode, we needed to implement a simple expression evaluator capable of doing additions and multiplications of single-digit numbers and with parenthesis.
For the second part, we need to implement operator precedence, but unlike real maths, in this exercise, an addition has precedence over multiplication.
Again, we could have written something based on RPN (https://wiki.c2.com/?PolishNotation) but instead, we decided to use an approach based on string manipulation (we split on operands and then map), plus some recursion.
All over, the solution is not too bad (even if arguably not the most academic!).
Let us know what you think and feel free to help us out with the code by sending us 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