# What is the probability that this is a "Wheel of Fortune" machine?

I recently took a HackerRank test for a Data Science position and got the following question wrong:

A casino has 10 slot machines. Eight of them are "Wheel of Fortune" themed, and two are "Jeopardy" themed. However, you do not know which machines are which. A "Wheel of Fortune" slot machine wins on 20% of spins which a "Jeopardy" machine wins on 50%. Say you play a round and are a winner. What is the probability that this is a "Wheel of Fortune" machine?

I used posterior probability to calculate this: WoF = Wheel of Fortune

J = Jeopardy

W = Win

L = Lost

P(WoF|W) = (P(W|WoF) * P(WoF)) / P(W)

P(WoF) = 80/100 = 4/5
P(W|WoF) = 20/100 = 1/5
P(W) = (20/100)*(8/10)+(50/100)*(2/10) = 13/50

P(WoF|W) = 8/13


I came up with the answer of 8/13. Can anyone help me identify what I did wrong?

• Why do you believe that you did something wrong? Do the HackerRant Test answer sheets give a different result? Sep 22, 2016 at 3:22

I am not convinced you did anything wrong here. Having looked at the work provided I suspected the answer was correct, so I went ahead and made a quick simulation in Python to test the answer you provided (8/13 or ~0.6154). Note that this simulation assumes the probability of picking a machine to play is uniform across all machines.

import random

machine_list = [1,1,0,0,0,0,0,0,0,0]

def pick():
p = random.randint(0,9)
return machine_list[p]

def play():
p = pick()
if p == 1: #J
w = random.randint(1, 2)
if w == 1:  # win
return 3
if w == 2:  # lose
return 4
if p == 0: #WoF
w = random.randint(1, 10)
if w <= 2:  # win
return 1
else:  # lose
return 2

winlist = []
woflist = []

for i in range(10000000):
p = play()
if p == 1 or p == 3:
winlist.append(p)
if p == 1:
woflist.append(p)

print len(woflist) / float(len(winlist))


With the following output:

0.615330464637