# 0 1 2 3 4 5 6 7 names = [" Ryan"," Kunj","Sagar","Kevin"," Jack"," Max"," Zack"," Mike"] records = [ [5,5] , [4,6] , [7,3] , [4,6], [7,3] , [4,6] , [7,3] , [2,8] ] res = [0,]*12 #outcomes/results matchups = [ [6,2], [5,1], [4,0], [7,3], \ [6,1], [0,5], [3,4], [2,7], \ [6,0], [5,3], [4,2], [7,1]] make_playoffs = [0,]*8 fight_for_spot = [0,]*8 def bit_add(L): l=L for k in range(len(l)): if l[k]==1: l[k]=0 else: l[k]=1 break return l trials = 0 for i in range(4096): if (res[0]==1 and res[1]==0 and res[2]==1 and res[3]==1 and res[4]==1 and res[5]==1 and res[6]==1 and res[7]==0): #constraint trials += 1 REC = [] for t in range(8): r = [records[t][0],records[t][1]] REC.append(r) if i == 4089: print "res = ", print res for m in range(12): game = matchups[m] w = game[res[m]] l = game[1-res[m]] REC[w][0]+=1 REC[l][1]+=1 standings = [] for t in range(8): final = (REC[t][0],t) standings.append(final) standings = sorted(standings,key=lambda tup: tup[0]) if i == 4089: print "standings = ", print standings if (standings[3][0]==standings[4][0]): #tie eq = [3,4] if (standings[3][0]==standings[2][0]): eq.append(2) if (standings[3][0]==standings[1][0]): eq.append(1) if (standings[3][0]==standings[0][0]): eq.append(0) if (standings[5][0]==standings[4][0]): eq.append(5) if (standings[6][0]==standings[4][0]): eq.append(6) if (standings[7][0]==standings[4][0]): eq.append(7) #eq = eq.sort() if len(eq)>3: print "eq = ", print eq,i print sorted(eq)[-1] for t in eq: fight_for_spot[standings[t][1]]+=1 for t in range(sorted(eq)[-1]+1,8): make_playoffs[standings[t][1]]+=1 else: for t in range(4,8): make_playoffs[standings[t][1]]+=1 res = bit_add(res) print "finished!" print make_playoffs print fight_for_spot print "There are 16=(2^4)^1 distinct outcomes for the remainder of the season, of which", print trials, print "were run. Amongst these ..." for t in range(8): print names[t], print "makes the playoffs outright", for i in range(2-len(str(make_playoffs[t]))): print "", print make_playoffs[t], print "times, and needs to win a tiebreaker", for i in range(2-len(str(fight_for_spot[t]))): print "", print fight_for_spot[t], print "times."