VLSI DV Interview Puzzles · All levels
Array Size Coupled to Content
What is P(len==4) under tuple counting, and why does this puzzle still demonstrate bidirectional solving?
Puzzle
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?
Code
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;
}
endclassHint
For each legal len, how many distinct data arrays satisfy foreach equality?
Step-by-step solution
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
Answer: P(len==4)=1/3; size and content are solved together, and content constraints can reduce tuple multiplicity to one per size.
Why candidates get it wrong
People assume longer arrays automatically imply more solutions, but deterministic element constraints can cancel that effect.
Interviewer follow-up
How would allowing data[i] inside {[0:1]} change len bias?