Advertisement
biswasrohit20

d5

Mar 21st, 2021
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 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. final = []
  22.  
  23. for x in vhtype:
  24. a = []
  25. sum = 0
  26. while True:
  27. ran = random.choice(list(q))
  28. if sum + q[ran] <= vhtype[x]:
  29. a.append({ran: q[ran]})
  30. sum += int(q[ran])
  31. del q[ran]
  32.  
  33. if sum >= vhtype[x]:
  34. break
  35. if len(q) == 0:
  36. break
  37. a.append({'Alimentation FC': 0})
  38. a.insert(0, {'Alimentation FC': 0})
  39. final.append(a)
  40.  
  41.  
  42. for i in range(len(final)):
  43. print(f'T{i+1} = ', final[i])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement