52 lines
963 B
Python
52 lines
963 B
Python
#!/usr/bin/python
|
|
|
|
import random
|
|
|
|
participants = [
|
|
'Maman',
|
|
'Papa',
|
|
'Mémé',
|
|
'Charlotte',
|
|
'Nico',
|
|
'Didi',
|
|
'Johnny',
|
|
'Ben',
|
|
'Ludo',
|
|
]
|
|
|
|
participants_recois = participants.copy()
|
|
|
|
on_evite = {
|
|
'Ben': 'Ludo',
|
|
'Charlotte': 'Nico',
|
|
'Maman': 'Papa',
|
|
'Didi': 'Johnny',
|
|
}
|
|
|
|
# On mélange les listes
|
|
random.shuffle(participants)
|
|
random.shuffle(participants_recois)
|
|
|
|
# On procède au tirage
|
|
tirage = dict()
|
|
for offre in participants:
|
|
while True:
|
|
recois = random.choice(participants_recois)
|
|
|
|
# Pas à soi même
|
|
if recois == offre:
|
|
continue
|
|
# On évite entre couple
|
|
if on_evite.get(offre) == recois or on_evite.get(recois) == offre:
|
|
continue
|
|
|
|
# Trouvé !
|
|
tirage[offre] = recois
|
|
participants_recois.remove(recois)
|
|
break
|
|
|
|
|
|
print("Résultat du tirage :")
|
|
for offre, recois in tirage.items():
|
|
print(" - %s -> %s" % (offre, recois))
|