Skip to content

Instantly share code, notes, and snippets.

@olafurw
Last active April 13, 2016 07:58
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 olafurw/f25eed747237a8e5d55cf5b9ce6674f1 to your computer and use it in GitHub Desktop.
Save olafurw/f25eed747237a8e5d55cf5b9ce6674f1 to your computer and use it in GitHub Desktop.
# Create 3 files, A.txt, B.txt, C.txt with your dice rolls, you can use https://www.random.org/integers/
# Make Magic(a,b,c) do the formula you think works.
# It will return how often each dice value was rolled
# A fair formula would result in equal results in each bracket for each dice
def FileToArray(aFilename):
with open(aFilename, 'r') as myFile:
return myFile.read().splitlines()
return []
# Put your magic here and return two numbers in a list like I did below
def Magic(a, b, c):
diceA = (a + (b % 3)) % 6
diceB = (c + (b % 3)) % 6
return [diceA, diceB]
A = FileToArray("a.txt")
B = FileToArray("b.txt")
C = FileToArray("c.txt")
diceACheck = [0, 0, 0, 0, 0, 0]
diceBCheck = [0, 0, 0, 0, 0, 0]
for idx, val in enumerate(A):
a = int(A[idx])
b = int(B[idx])
c = int(C[idx])
diceA, diceB = Magic(a, b, c)
diceACheck[diceA] = diceACheck[diceA] + 1
diceBCheck[diceA] = diceBCheck[diceA] + 1
print "Dice A"
print diceACheck
print "Dice B"
print diceBCheck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment