healths = [[1.0,[19,1,3,8,1,4,2]]] def results(healthList): multiplier = healthList[0] output = [] health = healthList[1] deads = health.count(0) odds = 1.0/(7-deads) for minion in range(0,7): if health[minion] != 0: tempHealth = [x for x in health] tempHealth[minion] -= 1 output += [[odds*multiplier,tempHealth]] return output for r in range(0,19): print "Currently on:" print r print "----" newhealths = [] for pair in healths: newhealths += results(pair) evennewerhealths = [] healthoptions = [] print "Length of newhealths:" print len(newhealths) print "----" for pair in newhealths: if pair[1] in healthoptions: for pair2 in evennewerhealths: if pair2[1] == pair[1]: pair2[0] += pair[0] else: healthoptions += [pair[1]] evennewerhealths += [pair] print "Length of evennewerhealths:" print len(evennewerhealths) print "----" middleodds = 0.0 for pair in evennewerhealths: if pair[1][0] == 20: middleodds += pair[0] print "Current Chance of no Face:" print middleodds print "----" healths = evennewerhealths finalodds = 0.0 for pair in healths: if pair[1][0] == 0: finalodds += pair[0] print finalodds
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question