|
| 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