diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-04-08 12:40:30 -0400 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-04-09 10:21:36 -0400 |
| commit | 9282e95e8844afe856ba76ceb6d2c3010df8bb1a (patch) | |
| tree | e35affc89b20324371381e079f7cb5f8a06aa81b /src/18/part2 | |
| parent | 2b5d4232879dc74491dabf54a0ddc958d66ebcec (diff) | |
| download | aoc2020-zig-master.tar.gz aoc2020-zig-master.zip | |
Diffstat (limited to 'src/18/part2')
| -rw-r--r-- | src/18/part2 | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/18/part2 b/src/18/part2 new file mode 100644 index 0000000..4110043 --- /dev/null +++ b/src/18/part2 @@ -0,0 +1,31 @@ +--- Part Two --- + +You manage to answer the child's questions and they finish part 1 of their homework, but get stuck +when they reach the next section: [1m[37madvanced[0m math. + +Now, addition and multiplication have [1m[37mdifferent[0m precedence levels, but they're not the +ones you're familiar with. Instead, addition is evaluated [1m[37mbefore[0m multiplication. + +For example, the steps to evaluate the expression 1 + 2 * 3 + 4 * 5 + 6 are now as follows: + +[1m[37m1 + 2[0m * 3 + 4 * 5 + 6 + 3 * [1m[37m3 + 4[0m * 5 + 6 + 3 * 7 * [1m[37m5 + 6[0m + [1m[37m3 * 7[0m * 11 + [1m[37m21 * 11[0m + [1m[37m231[0m + +Here are the other examples from above: + + + - 1 + (2 * 3) + (4 * (5 + 6)) still becomes [1m[37m51[0m. + - 2 * 3 + (4 * 5) becomes [1m[37m46[0m. + - 5 + (8 * 3 + 9 + 3 * 4 * 3) becomes [1m[37m1445[0m. + - 5 * 9 * (7 * 3 * 3 + 9 * 3 + (8 + 6 * 4)) becomes [1m[37m669060[0m. + - ((2 + 4 * 9) * (6 + 9 * 8 + 6) + 6) + 2 + 4 * 2 becomes [1m[37m23340[0m. + + +[1m[37mWhat do you get if you add up the results of evaluating the homework problems using these +new rules?[0m + + |
