Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutRoadmapCareersInternshipsFAQContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • Study Route: One Week Before the Interview
  • Study Route: Two Weeks
  • Study Route: Four Weeks (Full Course)4
  • OOP & Testbench Puzzles25
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
    • Classic Brain Teasers
    • Probability Puzzles
      • Biased Coin to Fair Bit (Von Neumann)
      • Expected Tosses Until First HH
      • Two Children, At Least One Boy
      • Monty Hall Switching Odds
      • Birthday Collision Threshold
      • Bayes on Failing Test Alerts
    • Digital Logic Puzzles
    • Debugging Riddles
    • Logic & Aptitude Puzzles: Tricky Q&A
  • Scenario & Debug Puzzles25
  • UVM Testbench Puzzles25
  • Clock, Reset & CDC Puzzles25
  • Bus and Interface Protocol Puzzles25
  • Interview Prep: Puzzle Rounds7
  • DV Puzzle Cheatsheet
Loading lesson

←Probability Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. Logic & Aptitude Puzzles
  4. Probability Puzzles
  5. Biased Coin to Fair Bit (Von Neumann)
On this page

    VLSI DV Interview PuzzlesAll levels

    Biased Coin to Fair Bit (Von Neumann)

    Given a biased coin with unknown P(H)=p, generate an unbiased bit and compute expected tosses per fair bit.

    Puzzle

    Difficulty: Medium · Puzzle 1 of 6 · Topic: Probability Puzzles

    Given a biased coin with unknown P(H)=p, generate an unbiased bit and compute expected tosses per fair bit.

    Hint

    Use two-toss ordered pairs and keep only anti-symmetric outcomes.

    Step-by-step solution

    Diagram
    1) Toss twice; outcomes are HH, HT, TH, TT.
    2) Emit 1 for HT, emit 0 for TH, reject HH and TT.
    3) Fairness: P(HT)=p(1-p) and P(TH)=(1-p)p, so both outputs are equiprobable.
    4) Acceptance probability per 2-toss trial is P(HT or TH)=2p(1-p).
    5) Expected accepted-trial count is 1/[2p(1-p)].
    6) Multiply by 2 tosses per trial => expected tosses = 1/[p(1-p)].

    Answer

    Answer: Use HT/TH mapping; expected tosses per unbiased bit are 1/(p(1-p)).

    How this was checked

    Checked by running a model of the rule in a Python model. A computational check: exact fractions show HT and TH are equally likely and the expected tosses equal 1/(p(1-p)); a fixed-seed simulation shows the Peres extractor yields about 0.85 fair bits per toss versus 0.21 for plain von Neumann at p = 0.3.

    Why candidates get it wrong

    Applying a single toss plus a threshold: with unknown p there is no threshold that yields 50/50. The pair trick works because HT and TH have the same probability p(1-p) for every p.

    Interviewer follow-up

    Can you design a streaming variant that wastes fewer tosses on average? Model answer: yes, the Peres (iterated von Neumann) extractor. Besides the HT/TH bit it also feeds the discarded information back in: the sequence of 'pair was equal or not' and the values of the equal pairs (HH->H, TT->T) are recursively extracted again. It gets close to the entropy limit H(p) bits per toss instead of p(1-p) bits per toss.

    Say it out loud

    I toss the coin twice, and I keep the pair only if the two tosses differ. Heads then tails has probability p times one minus p, and tails then heads has the same probability, so I output one for head-tail and zero for tail-head, and the bit is fair for every p. Each pair is accepted with probability two p times one minus p, and each pair costs two tosses, so the expected number of tosses per fair bit is one over p times one minus p. The trap is using a single toss with a threshold, which cannot give fifty-fifty when p is unknown.

    Related topics

    • Back to Probability Puzzles

    • Logic & Aptitude Puzzles section

    Previous

    167 / 293

    Next: Expected Tosses Until First HH

    Up next

    Up nextExpected Tosses Until First HH

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • Two Children, At Least One Boy
    • Monty Hall Switching Odds
    • Birthday Collision Threshold