VLSI DV Interview Puzzles · All levels
m<n Cardinality Bias
Compute P(n==4) without solve-before, then estimate what solve n before m does.
Puzzle
Difficulty: Medium · Puzzle 4 of 6 · Topic: solve...before Bias Puzzles
Compute P(n==4) without solve-before, then estimate what solve n before m does.
Code
systemverilog
class sb_mn;
rand int unsigned n;
rand int unsigned m;
constraint c {
n inside {[1:4]};
m inside {[0:3]};
m < n;
}
// Variant: solve n before m;
endclassHint
Count legal m values for each n.
Step-by-step solution
diagram
1) n=1 allows m={0} (1 tuple), n=2 allows {0,1} (2), n=3 allows {0,1,2} (3), n=4 allows {0,1,2,3} (4).
2) Total tuples = 1+2+3+4 = 10.
3) Baseline P(n==4)=4/10=0.4.
4) With solve n before m, many solvers choose n near-uniform first (~1/4 each), then solve m in chosen branch.
5) Legal solutions are unchanged.Answer
Answer: Without solve-before, P(n==4)=40%; with solve n before m, n often moves toward ~25% each value while legal tuples stay the same.
Why candidates get it wrong
A common mistake is saying n is uniform just because its domain is 1..4.
Interviewer follow-up
How would you keep tuple-order solving but still get n uniform?