Jane Street Interview Question

Simulate a 6 sided die with a coin.

Interview Answers

Anonymous

Oct 31, 2011

HHH, TTT, start the process again. Assign the rest values of dice. HHT = 1 HTH = 2 HTT = 3 THH = 4 THT = 5 TTH = 6

8

Anonymous

Apr 8, 2011

Toss three coins, we get 8 outcomes: HHH, HHT, HTH, HTT, THH, THT, TTH, TTT, for the first two, we toss again until neither HHT or HHT appears, for the remaining 6, we assign 1~6 individually.

11

Anonymous

Jul 11, 2011

Nope. I'm a moron. Can't edit earilier post, but Ey, sorry, I gave you too much credit. Can't count HT and TH as the same thing because you get too many of them. No idea why I didn't see that 10 minutes ago. You can't map 4 coin results to three numbers fairly. You will end up with too many 2s and 5s and way too many 6s with your solution. Now we have no valid answers. I think someone proved it can't be done elsewhere. Interesting problem though.

Anonymous

Jul 12, 2011

Eric, you're right, I thought my solution worked as well. My idea was that we do 2 independent 2-coin flips. Each 2 coin flip has the following possible outcome: HH, TT, HT(or TH, same thing). When combining the outcomes of the 2 independent 2 coin flips this is what we get: (1) HH (2) HH (1) HH (2) HT (1) HH (2) TT (1) TT (2) HH (1) TT (2) HT (1) TT (2) TT (1) HT (2) HT (1) HT (2) HH (1) HT (2) TT we get 9 possible outcomes, even if we set for example outcomes (1) HH (2) TT to be equivalent to (1) TT (2) HH, and similarly with others to get 6 outcomes, it won't work...

Anonymous

Nov 1, 2011

Geez, they should really allow for nested responses for better discussions. I agree that with the approach first stated by William (except he had a typo, "HHT or HHT appears" should read "HHH or HHT appears" he was just referring to first two (or any two of the eight combination that one chooses not to assign values to). The way that "Do three flips" describes is clearer. Other approaches are problematic in that the chances of getting 1-6 are disproportionate leading to an unfair dice (for reasons that others stated). "Binary Thinkers" approach is also incorrect as for similar reasons. there 8 possible accounts (3 flips 2^3 = 8). Although it's a unique way to account for all the numbers 1 through 6... 3's are and 4's are precisely twice as likely to occur (2/8 or 1/4 chance) vs the other numbers (1/8 chance).

Anonymous

Dec 28, 2014

You may ask for a probability of THHHHH if we get a consequent combination with 5 heads and one tail. Here are the 6 possible combinations: THHHHH HTHHHH HHTHHH HHHTHH HHHHTH HHHHHT so the probability of each is 1/6

Anonymous

Mar 8, 2016

Not a precise solution, but good enough for many purposes: Flip the coin a large number of times, interpret the result as number in base 2, and take it modulo 6. Some of the six numbers will be slightly disadvantaged, but you can make that difference arbitrarily small by increasing the number of coin flips.

Anonymous

Jul 11, 2011

Toss 1: Heads=even, start with 2, tails=odd, start with 1 Toss 2: Heads=0, tails=2, add to total Toss 3: Heads=0, tails=2, add to total

Anonymous

Jul 9, 2011

With 1 coin, flip three times and HHH=1,HHT=2, HTH=3,HTT=4, THH=5, THT=6. If the first twice is TT, then abandon the first T and start with the second T.

1

Anonymous

Jul 11, 2011

The candidate and William have problems. I think Ey's solution works. For the candidate's solution, you will get way more 5s and 6s, since fully 1/2 of the results will be either a 5 or a 6. Similarly, for William's solution, if you toss out results starting with HH, then you end up with ANY result that starts with a tail, and only half the results that start with a H. That means you will end up with more 3s, 4s, 5s, and 6s than you should. I think by simply changing what you throw out you could fix William's solution. If you threw out all HHH and all TTT you would be closer, but a solution where you don't toss out any data is still better.

Anonymous

Jul 11, 2011

It cannot be done. The odds of any set of coin flips is always a power of 2, and there is no power of 2 for which 6 is a factor, because 6 factors to 2 * 3 and both are prime numbers.

Anonymous

May 17, 2011

I propose another solution. Use 4 coins. Flip 2 coins together and separately another 2 coins together. Sample space for a 2 coin flip is: HH, TT, HT, TH (assume that HT=TH) For the two 2-coin flips assign value of dice, for example (column 1: 2 coin flip, column 2 other 2-coin flip) HH HH => 1 HH HT/TH => 2 HH TT => 3 TT TT => 4 TT HT=> 5 HT HT=> 6 with TH=HT

Anonymous

Apr 7, 2011

split into two sets {1,2,3,4} {5,6} with one assigned to heads and the others tails. If in the {5,6} set flip again. If in the {1,2,3,4} set assign {1,2} to heads and {3,4} to tails. then split again.

4