r/adventofcode • u/pedrosorio • Dec 07 '17
Help "exactly one program is the wrong weight" - ambiguous?
Did I missing something in the problem description? Since we're not given whether the program with wrong weight is too light or too heavy, this is ambiguous if the program with wrong weight is on top of a program with "two children", right?
Example prog (10) has two children prog1 (11) and prog2 (12). It's impossible to tell which one has the wrong weight (or should we interpret this as a situation where "2 problems have a wrong weight"?)
After thinking for a while I reasoned "you will be given an input where there is a single problem with the wrong weight and it is possible to determine it unambiguously" (in other words, the problem with wrong weight must be the child of a program with 3 or more programs).
Did anyone else find it confusing?
13
u/topaz2078 (AoC creator) Dec 07 '17
It's still possible to determine unambiguously; the wrongly-weighted node is never on a layer with only two nodes.
3
u/asger_blahimmel Dec 07 '17
The inputs given will always have a unique solution, and I'm fine with this.
But I also played with the idea of two different weights, and realised, that they don't always lead to ambiguity. Consider the following example:
rootwill be unbalanced, asleftweighs 1, butrightand its children have a total weight of 3. However, if we assume every disc has a non-negative weight, it is impossible forrightto have a wrong weight - because the correct weight cannot be -1. The only possible solution in this case is thatlefthas a wrong weight, as it should be 3.2
u/Vapter Dec 07 '17
This really frustrated me as well, since I was trying to solve the case where a program that balances two more programs on top of it, until I realized it is unsolvable since we do not know which of the two programs is has the "wrong weight". Especially since the input does contain programs with two child programs.
2
u/pwmosquito Dec 07 '17
Yup, I had the same question. Description should explicitly rule this out.
2
u/jonenst Dec 08 '17
I was also slightly frustrated (but I know it's hard to come up with perfect problems !) because the following input is unambiguous, but most solutions crash on it
The answer must e ( 1 ), but you have to deduce this from the fact that the weight of b + e + f must be 3 because 2 other towers have a weight of 3, and b can not be changed because its children are already unbalanced, and chose e ( 1 ) over f ( 2 ) because of the weight of the subtower b e f
So in the end, we don't write programs that solve the problem in the general case, but on a simple input.
1
u/hpzr24w Dec 07 '17
Here's my debugging output for the example:
And for my actual problem, just showing the balancing step (part 2):
So it looks like the output should be nice to us.
1
u/sclark39 Dec 08 '17
I believe I did this right... here's some ambiguous input based on the original example data:
I believe this would have two solutions. Solving it in the recursion loop is tricky.