#!/usr/bin/python import numpy as np ##### input section ##### n = 10000000 # number of throws (4 dice each) ##### input section ##### a = np.random.randint(1,7,n*4).reshape(4,n) # build the array of the n throws of 4 dice b = np.where(a.sum(axis=0)<10,1,0) # elements of b are 1 if sum of rows are less than 10, otherwise they are set to 0 print 'prob %g of winning out of %g throws' % (b.sum()/float(b.size), b.size)