Searching for most pythonic/least stupid way to do something simple
nn
pruebauno at latinmail.com
Tue Mar 16 09:48:11 EDT 2010
david jensen wrote:
> ... and of course i screwed up my outcomes... that should read
> outcomes=[[4,3,8,3,5],[3,4,8,3,5],[2,5,8,3,5],[1,6,8,3,5],[0,7,8,3,5]]
For starters:
def getOutcomes(myList=[2,5,8,3,5]):
low_id = int(myList[0]>myList[1])
amountToShare = 2*myList[low_id]
remainder = myList[not low_id]-myList[low_id]
tail=myList[2:]
outcomes = [[amountToShare*perc, remainder+amountToShare*(1-perc)]
+ tail
for perc in (1.0, 0.75, 0.5, 0.25, 0.0)]
return outcomes
More information about the Python-list
mailing list