|
|
|
|
|
by keenerd
4151 days ago
|
|
[edit; whoops you were talking about the format and I was talking about the material. Oh well, hopefully this is not too out of place.] It could be made much more approachable by removing the math entirely. If you learned programming before algebra you might have solved it like this: from random import random
from collections import defaultdict
tally = defaultdict(int)
for i in range(100000):
thief = ['raccoon', 'fox'][random() < 0.3]
bear = ['false', 'true'][random() < 0.8]
hair = ['raccoon', 'fox'][random() < 0.3333333]
if thief == 'raccoon' and bear == 'true':
continue
if thief == 'fox' and bear == 'false':
continue
if thief != hair:
continue
tally[thief] += 1
print(sorted(tally.items()))
While crude it does give the correct answer, to within 1% or so. |
|