Skip to content

Instantly share code, notes, and snippets.

@Deathnerd
Created July 13, 2014 19:49
Show Gist options
  • Save Deathnerd/cd4e8146012709747856 to your computer and use it in GitHub Desktop.
Save Deathnerd/cd4e8146012709747856 to your computer and use it in GitHub Desktop.
__author__ = 'deathnerd'
combinations = list()
for i in range(1, 7):
for j in range(1, 7):
for k in range(1, 7):
#this appends a list (a type of array) to the combinations list
combinations.append([k, j, i])
number_less_than_or_equal_to_sixty = 0.0
for combo in combinations:
# python is 0 indexed, so 0 is the first element in the array followed by 1, 2, 3, etc.
x = combo[0]
y = combo[1]
z = combo[2]
if (x+y+z)*10 <= 60:
number_less_than_or_equal_to_sixty += 1
#float makes it into a decimal
length_of_list = float(combinations.__len__())
ratio = number_less_than_or_equal_to_sixty/length_of_list
# %.6f means print the variable after the % after the string (text) as a float with 6 precision points
print "Your character has a %.6f chance of being mentally retarded" % ratio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment