Skip to content

Commit ec09031

Browse files
Secret Santa Program
1 parent 9fa729e commit ec09031

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

OTHERS/Secret Santa Program/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Description:
2+
3+
This is a program used to assign people a person anonymously within a group.
4+
5+
Note: This program was created out of boredom.
6+
7+
# How to use:
8+
9+
1. Write numbers 1 to n people for how many would like to participate on paper.
10+
2. Fold or scrunch up the numbers and shuffle.
11+
3. Each individual draws a number.
12+
4. Run main.py.
13+
5. Follow Steps.
14+
6. Should there be any players remaining not present, screenshot the results and give them a number without looking.

OTHERS/Secret Santa Program/main.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import os
2+
import numpy as np
3+
4+
command = input("Input command (A Name, Remove, Exit): ")
5+
groupList = []
6+
7+
8+
def printList(list):
9+
for name in list:
10+
print(name[0])
11+
12+
13+
def printTrueList(list):
14+
print("\nDEBUGGING ONLY:\n")
15+
for name in list:
16+
print(name)
17+
18+
19+
def randomise(groupList):
20+
lengthList = list(range(1, len(groupList) + 1))
21+
groupNumberList = []
22+
nameList = []
23+
trueList = []
24+
Toggle = True
25+
26+
for i in groupList:
27+
groupNumberList.append(i[1])
28+
nameList.append(i[0])
29+
30+
while Toggle:
31+
np.random.shuffle(lengthList)
32+
for i in range(len(groupNumberList)):
33+
if groupNumberList[i] == lengthList[i]:
34+
Toggle = True
35+
break
36+
else:
37+
Toggle = False
38+
39+
for i in range(len(groupList)):
40+
trueList.append((lengthList[i], groupNumberList[i]))
41+
42+
for i in trueList:
43+
print(i[0], "-->", nameList[i[1] - 1])
44+
45+
46+
def groupMaker(command):
47+
while True:
48+
if command.upper() == "EXIT":
49+
os.system('clear')
50+
print("All names:\n")
51+
printList(groupList)
52+
53+
print("\n How the Assignment Works:")
54+
print(
55+
"The person holding the number is assigned \nthe person to the right of the arrow \n"
56+
)
57+
randomise(groupList)
58+
break
59+
60+
elif command.upper() == "REMOVE":
61+
print("")
62+
for i, c in enumerate(groupList):
63+
print(f'{i+1} {c[0]}')
64+
choice = input("\nWho do you want to remove? (Insert Index Number): ")
65+
groupList.pop(int(choice) - 1)
66+
os.system('clear')
67+
68+
else:
69+
number = input("\nWhat is your number?: ")
70+
while True:
71+
choice = input("Is your number correct? (Yes, No): ")
72+
if choice.upper() == "YES":
73+
break
74+
elif choice.upper() == "NO":
75+
number = input("\nWhat is your number?: ")
76+
else:
77+
pass
78+
groupList.append((command.lower().capitalize(), int(number)))
79+
os.system('clear')
80+
81+
print("Current people in the group")
82+
printList(groupList)
83+
command = input("Input command (a name, REMOVE, EXIT): ")
84+
85+
86+
groupMaker(command)

0 commit comments

Comments
 (0)