import time
import random
print("=" * 60)
print("\t\t\t\t\tSorteio Amigo Secreto")
print("=" * 60)
time.sleep(3)
print("\n")
print("=" * 60)
print("\t\t\t\t\t\t\tMENU")
print("=" * 60)
time.sleep(2)
def sortear_amigo_secreto(participantes):
amigos = participantes.copy()
random.shuffle(amigos)
sorteio = {}
n = len(participantes)
for i in range(n):
sorteio[participantes[i]] = amigos[(i + 1) % n]
return sorteio
print("\t\t\t\t\t1 - Sorteio\n\t\t\t\t\t2 - Sair")
escolha = True
while escolha:
opcao = input("Digite a opção: ")
if opcao == "1":
participantes = []
while True:
nome = input("Digite o nome de um participante (ou 's' para sair): ").lower()
if nome == 's':
if len(participantes) < 2:
print("É necessário pelo menos 2 participantes para realizar o sorteio.")
participantes.clear()
else:
break
elif nome in participantes:
print("Este nome já foi inserido. Por favor, insira um nome único.")
else:
participantes.append(nome)
resultado = sortear_amigo_secreto(participantes)
print("\nResultados do sorteio de Amigo Secreto:")
for participante, amigo in resultado.items():
print(f"{participante} -> {amigo}")
elif opcao == "2":
total = 100
print("Carregando...")
for i in range(total + 1):
time.sleep(0.05)
percentagem = (i / total) * 100
barra = "#" * i + "-" * (total - i)
print(f"\r[{barra}] {percentagem:.2f}%", end="", flush=True)
print("\nPrograma Fechado")
break
else:
print("Erro! Valor digitado inválido.")