-
-
Save AijaLi/d1bf82baf4a31f36acc6 to your computer and use it in GitHub Desktop.
Secret Santa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
people = ["Andis", "Anna", "Beatrise", "Cilda", "Druvis", "Evalds", "Fanija", "Gatis", "Grieta", "Ieva", "Indulis", "Janis C.", "Janis V.", "Peteris", "Raita"] | |
couples = [["Anna", "Janis V."], ["Ieva", "Gatis"], ["Andis", "Raita"]] | |
couple_found = True | |
while(couple_found == True): | |
# samaisa cilveku sarakstu un parbauda parus | |
random.shuffle(people) | |
#print people | |
cur_couple = 0 | |
while(cur_couple < len(couples)): | |
# parbauda, vai paris neatrodas saraksta viens otram lidzas vai saraksta galos | |
person_1_idx = people.index(couples[cur_couple][0]) | |
person_2_idx = people.index(couples[cur_couple][1]) | |
if(person_1_idx == person_2_idx + 1 or person_1_idx == person_2_idx - 1 or (person_1_idx == 0 and person_2_idx == len(people)-1) or (person_2_idx == 0 and person_1_idx == len(people)-1)): | |
couple_found = True | |
break | |
else: | |
cur_couple += 1 | |
couple_found = False | |
# izdruka sarakstu | |
for p in range(0, len(people)): | |
if(p == len(people)-1): | |
print people[p] + " davina davanu " + people[0] | |
else: | |
print people[p] + " davina davanu " + people[p+1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment