Advertisement
biswasrohit20

d6

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