Skip to content

Instantly share code, notes, and snippets.

# Rope Burning Riddler from fivethirtyeight.com
def explore(situation):
ropes = situation[0]
time = situation[1]
# Find unextinguished ropes and make a list of those
# with at least 1 unlit end.
allextinguished = True
Testimony = [[0,[0,2,5,6,7]],[0,[1,3,4,6,7]],[0,[1,2,3,4,6]],[0,[0,1,3,4,6]],\
[1,[0,2,4,5,7]],[1,[1,3,4,5,6]],[1,[0,2,3,5,7]],[1,[0,1,2,5,7]]]
for liars in range(0,255):
success = 1
for witness in Testimony:
if sum([(liars&2**i)//2**i for i in witness[1]])%2 == witness[0]:
success = 0
if success: print("{0:08b}".format(liars))
@hectorpefo
hectorpefo / bearsalmon.tex
Created August 8, 2016 20:05
Bear Salmon Riddler
First the intuitive case. Passing up on the first fish won't turn out to have been a win if the second fish is bigger, because she could have eaten both. And if the second is smaller, if the bear passed up on the first, she's eating a smaller fish than she would have if she had eaten the first. So, whether the second fish is bigger or smaller than the first, the bear will be glad she ate the first.
For three fish: If the second fish is bigger than the first, then she gets to eat both and will be glad she did, whether the third fish is smaller or bigger still. If the second fish is smaller than the first, though, there is a chance that the third will be in between them in size, and that together, the second and third will weigh more than the first, in which case she'd have done better passing on the first. So for three fish there is no ``dominance" style argument (no choice invariably leads to the best outcome), and the numbers matter.
In the two-fish case, Let the first fish $A$ weigh $a$ and the second,
import random
num_trials = 100000
total_ones = 0
for dummy in range(1,num_trials):
missing = [1,1,1]
while not (missing == [0,0,0]):
gem = [0,0,0,1,1,2][random.randint(0,5)]
missing[gem] = 0
if gem == 0: total_ones += 1
print ("Result is ",total_ones/num_trials)