Advertisement
biswasrohit20

d3

Mar 21st, 2021
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import random
  2.  
  3. vhtype= {'T1': 5, 'T2': 10, 'T3': 15, 'T4': 20}
  4. q= {'Alimentation FC': 0,
  5. 'Paris Grill': 1,
  6. 'Continental': 1,
  7. 'Paillard': 1,
  8. "L'Ostrea": 1,
  9. 'Lavieille': 1,
  10. "L'Omelette": 3,
  11. 'Le Café du Monde': 3,
  12. "Au Palet d'Or": 3,
  13. 'Le Saint-Amour': 3,
  14. 'Bistro St-Malo': 3,
  15. 'Au Petit Coin Breton Ltee': 5,
  16. 'France Benoit': 5,
  17. 'La Chic Shack': 5,
  18. 'Les délices de Candice ': 5,
  19. 'Restaurant Toast': 5}
  20.  
  21.  
  22. for x in vhtype:
  23. a = []
  24. m = q.copy()
  25. sum = 0
  26. while True:
  27. ran = random.choice(list(m))
  28. if sum + m[ran] <= vhtype[x]:
  29. a.append({ran: m[ran]})
  30. sum += int(m[ran])
  31. del m[ran]
  32.  
  33. if sum >= vhtype[x]:
  34. break
  35. a.append({'Alimentation FC': 0})
  36. a.insert(0,{'Alimentation FC': 0})
  37. print(x,"=",a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement