|
| 1 | +defmain(): |
| 2 | +# Sprinkles: capacity 2, durability 0, flavor -2, texture 0, calories 3 |
| 3 | +# Butterscotch: capacity 0, durability 5, flavor -3, texture 0, calories 3 |
| 4 | +# Chocolate: capacity 0, durability 0, flavor 5, texture -1, calories 8 |
| 5 | +# Candy: capacity 0, durability -1, flavor 0, texture 5, calories 8 |
| 6 | +ingredients= [{'cap':2,'dur':0,'fla':-2,'tex':0,'cal':3}, |
| 7 | + {'cap':0,'dur':5,'fla':-3,'tex':0,'cal':3}, |
| 8 | + {'cap':0,'dur':0,'fla':5,'tex':-1,'cal':8}, |
| 9 | + {'cap':0,'dur':-1,'fla':0,'tex':5,'cal':8}] |
| 10 | + |
| 11 | +defprop_score(prop,s,b,c,a): |
| 12 | +returnmax(0,sum([ingredients[i][prop]*ingrfor (i,ingr)in [(0,s),(1,b),(2,c),(3,a)]])) |
| 13 | + |
| 14 | +score=0 |
| 15 | +score_cal=0 |
| 16 | +forsinxrange(1,100): |
| 17 | +forbinxrange(1,100-s): |
| 18 | +forcinxrange(1,100-s-b): |
| 19 | +a=100-s-b-c |
| 20 | +props= [] |
| 21 | +forpropin ['cap','dur','fla','tex']: |
| 22 | +props.append(prop_score(prop,s,b,c,a)) |
| 23 | +new_score=reduce(lambdax,y:x*y,props,1) |
| 24 | +score=max(score,new_score) |
| 25 | +ifprop_score('cal',s,b,c,a)==500: |
| 26 | +score_cal=max(score_cal,new_score) |
| 27 | +print(score) |
| 28 | +print(score_cal) |
| 29 | + |
| 30 | + |
| 31 | +if__name__=="__main__": |
| 32 | +main() |