Difficulty: Hard · Puzzle 6 of 6 · Topic: Constraint Solving Order Puzzles
What is P(len==4) under tuple counting, and why does this puzzle still demonstrate bidirectional solving?
class size_content;
rand int unsigned len;
rand byte data[];
constraint c {
len inside {[2:4]};
data.size() == len;
foreach (data[i]) data[i] == i;
}
endclassFor each legal len, how many distinct data arrays satisfy foreach equality?
1) len can be 2,3,4.
2) For each len, foreach constraint fixes data uniquely to {0..len-1}.
3) So each len contributes exactly one legal tuple in joint space.
4) Total tuples=3 and exactly one has len==4 -> P(len==4)=1/3.Answer: P(len==4)=1/3; size and content are solved together, and content constraints can reduce tuple multiplicity to one per size.
People assume longer arrays automatically imply more solutions, but deterministic element constraints can cancel that effect.
How would allowing data[i] inside {[0:1]} change len bias?