From 64be6ab685383b922fb8509e4c3e5607705e52bc Mon Sep 17 00:00:00 2001 From: Colombain Agathe <agathe.colombain@student-cs.fr> Date: Sun, 30 Mar 2025 20:12:52 +0000 Subject: [PATCH] Upload New File --- testtirageausort.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 testtirageausort.py diff --git a/testtirageausort.py b/testtirageausort.py new file mode 100644 index 0000000..b100da9 --- /dev/null +++ b/testtirageausort.py @@ -0,0 +1,23 @@ +import random + + +##Les noms des participants et leurs mails sont ici fictifs pour ne délivrer aucune information personnelle +participants_names = ['Alice', 'Bob', 'Charlie', 'Dana'] +participants_emails = ['alice@example.com', 'bob@example.com', 'charlie@example.com', 'dana@example.com'] + +def tirageausort(names, emails): + results = [] + while True: + shuffled_names = names.copy() + random.shuffle(shuffled_names) + if all(giver != receiver for giver, receiver in zip(names, shuffled_names)): + break + for i, name in enumerate(names): + giver = names[i] + receiver = shuffled_names[i] + receiver_email = emails[names.index(receiver)] + + results.append((i, receiver)) + return results + +print(tirageausort(participants_names, participants_emails)) \ No newline at end of file -- GitLab