Skip to content

Instantly share code, notes, and snippets.

@geidsmoe
Created February 6, 2019 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geidsmoe/31bf0f60bf18dd5387ee3a81ba204cd5 to your computer and use it in GitHub Desktop.
Save geidsmoe/31bf0f60bf18dd5387ee3a81ba204cd5 to your computer and use it in GitHub Desktop.
Riddler Classic 2/1/2019
import numpy as np
def war(h1, h2):
h1_wins = 0
h2_wins = 0
for c1, c2 in zip(h1, h2):
if c1 > c2:
h1_wins += 1
else:
h2_wins += 1
if h1_wins == 5:
return 0
elif h2_wins == 5:
return 1
def hand_setup():
red = [14]*4 + [9]*4 + [7]*4
blue = [13]*4 + [11]*4 + [6]*4
black = [12]*4 + [10]*4 + [8]*4
hands = [red, blue, black]
for h in hands:
np.random.shuffle(h)
return hands
def endless_war():
redvblue = [0,0]
redvblack = [0,0]
bluevblack = [0,0]
for i in xrange(1000000):
red, blue, black = hand_setup()
redvblue[war(red, blue)] += 1
redvblack[war(red, black)] += 1
bluevblack[war(blue, black)] += 1
print "Red v. Blue: " + str(redvblue)
print "Red v. Black: " + str(redvblack)
print "Blue v. Black: " + str(bluevblack)
endless_war()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment