aoc-2020-zig

Advent of Code 2020 Solutions in Zig
git clone https://git.sinitax.com/sinitax/aoc-2020-zig
Log | Files | Refs | README | sfeed.txt

part2 (1143B)


      1--- Part Two ---
      2
      3You manage to answer the child's questions and they finish part 1 of their homework, but get stuck
      4when they reach the next section: advanced math.
      5
      6Now, addition and multiplication have different precedence levels, but they're not the
      7ones you're familiar with. Instead, addition is evaluated before multiplication.
      8
      9For example, the steps to evaluate the expression 1 + 2 * 3 + 4 * 5 + 6 are now as follows:
     10
     111 + 2 * 3 + 4 * 5 + 6
     12  3   * 3 + 4 * 5 + 6
     13  3   *   7   * 5 + 6
     14  3   *   7   *  11
     15     21       *  11
     16         231
     17
     18Here are the other examples from above:
     19
     20
     21 - 1 + (2 * 3) + (4 * (5 + 6)) still becomes 51.
     22 - 2 * 3 + (4 * 5) becomes 46.
     23 - 5 + (8 * 3 + 9 + 3 * 4 * 3) becomes 1445.
     24 - 5 * 9 * (7 * 3 * 3 + 9 * 3 + (8 + 6 * 4)) becomes 669060.
     25 - ((2 + 4 * 9) * (6 + 9 * 8 + 6) + 6) + 2 + 4 * 2 becomes 23340.
     26
     27
     28What do you get if you add up the results of evaluating the homework problems using these
     29new rules?
     30
     31