Guest User

yahtzee possibilities code

a guest
Jul 27th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. count = 0
  2. f = open('test.txt', 'w')
  3. for i in [x+1 for x in range(6)]:
  4.     for j in [x+1 for x in range(6)]:
  5.         if (i==1 and j==4) or (i==6 and j==4) or (i==4 and j==1) or (i==4 and j==6):
  6.             f.write('+')
  7.             f.write(str(i) + ' ' + str(j) + '\n')
  8.             count += float(1)/36
  9.         else:
  10.             for k in [x+1 for x in range(6)]:
  11.                 if i==4 or j==4:
  12.                     if k==1 or k==6:
  13.                         f.write('+')
  14.                         count += float(1)/216
  15.                     f.write(str(i) + ' ' + str(j) + ' ' + str(k) + '\n')
  16.                 else:
  17.                     for l in [x+1 for x in range(6)]:
  18.                         if (k==1 and l==4) or (k==6 and l==4) or (k==4 and l==1) or (k==4 and l==6):
  19.                             f.write('+')
  20.                             count += float(1)/1296
  21.                         f.write(str(i) + ' ' + str(j) + ' ' + str(k) + ' ' + str(l) + '\n')
  22. print count
  23. f.close()
Advertisement
Add Comment
Please, Sign In to add comment