Skip to content

Instantly share code, notes, and snippets.

@AijaLi
Created November 22, 2014 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AijaLi/d1bf82baf4a31f36acc6 to your computer and use it in GitHub Desktop.
Save AijaLi/d1bf82baf4a31f36acc6 to your computer and use it in GitHub Desktop.
Secret Santa
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