From 8f5ccfc0d5049c421594a8fb15a8e7c4ffc026b4 Mon Sep 17 00:00:00 2001 From: Kees van Kempen Date: Sun, 29 Dec 2024 00:22:08 +0100 Subject: [PATCH] 2024(7): fetch assignment part 2 --- 2024/07/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/2024/07/README.md b/2024/07/README.md index 07e6af0..771bc88 100644 --- a/2024/07/README.md +++ b/2024/07/README.md @@ -38,3 +38,19 @@ Only three of the above equations can be made true by inserting operators: The engineers just need the _total calibration result_, which is the sum of the test values from just the equations that could possibly be true. In the above example, the sum of the test values for the three equations listed above is _`3749`_. Determine which equations could possibly be true. _What is their total calibration result?_ + +### Part Two + +The engineers seem concerned; the total calibration result you gave them is nowhere close to being within safety tolerances. Just then, you spot your mistake: some well-hidden elephants are holding a _third type of operator_. + +The [concatenation](https://en.wikipedia.org/wiki/Concatenation) operator (`||`) combines the digits from its left and right inputs into a single number. For example, `12 || 345` would become `12345`. All operators are still evaluated left-to-right. + +Now, apart from the three equations that could be made true using only addition and multiplication, the above example has three more equations that can be made true by inserting operators: + +* `156: 15 6` can be made true through a single concatenation: `15 || 6 = 156`. +* `7290: 6 8 6 15` can be made true using `6 * 8 || 6 * 15`. +* `192: 17 8 14` can be made true using `17 || 8 + 14`. + +Adding up all six test values (the three that could be made before using only `+` and `*` plus the new three that can now be made by also using `||`) produces the new _total calibration result_ of _`11387`_. + +Using your new knowledge of elephant hiding spots, determine which equations could possibly be true. _What is their total calibration result?_