import numpy as np
import hashlib
# 추첨 인원수
winner_num = 3
# BOJ 연습란을 텍스트로 긁어오면 됩니다 (랭킹, 아이디, A, B, C, ... 맨 윗줄 제외하고)
info = """
1 yookwi 1 / 3723 2 / 3723 2 / 3714 1 / 2611 1 / 2604 3 / 2604 1 / 1569 7 / 3803
2 hms0510 1 / 5544 3 / 5560 4 / 7085 3 / 8439 0 / -- 0 / -- 0 / -- 4 / 8579
3 glnthd02 1 / 2514 1 / 2518 3 / -- 0 / -- 1 / 2579 0 / -- 0 / -- 3 / 2579
4 kdh9158kdh 4 / 1005 1 / 5831 6 / 8686 0 / -- 0 / -- 0 / -- 0 / -- 3 / 8846
5 rlawoaks 1 / 704 2 / 711 1 / -- 0 / -- 0 / -- 0 / -- 0 / -- 2 / 731
6 jjhlemon 1 / 822 1 / 849 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 2 / 849
7 h1234000 1 / 2463 1 / 2486 2 / -- 0 / -- 0 / -- 0 / -- 0 / -- 2 / 2486
8 mhw0502 2 / 3759 1 / 3769 4 / -- 0 / -- 0 / -- 0 / -- 0 / -- 2 / 3789
9 likescape 0 / -- 0 / -- 0 / -- 0 / -- 3 / -- 0 / -- 0 / -- 0 / 0
"""
info = info.splitlines(keepends = True)
if info[0] == "\n": info.pop(0)
# 랜덤 시드
mod = 4294967296 # 2^32
seed_string = "AlKon0525"
random_seed = int.from_bytes(hashlib.sha256(seed_string.encode()).digest(), 'big') % mod
np.random.seed(random_seed)
participants = {}
for participant in info:
participant = participant.split('\t')
user = participant[1]
corrects = int(participant[-1].split(' / ')[0])
if user in participants:
participants[user] = max(participants[user], corrects + 3)
else: participants[user] = corrects + 3
# 추첨 명단 제외 리스트
except_list = ['aerae']
for except_user in except_list:
try:
participants.pop(except_user)
except:
pass
# 추첨 확률 설정
winner_percent = [0] * len(participants)
correct_problems_sum = sum(participants.values())
for i, corrects in enumerate(list(participants.values())):
winner_percent[i] = corrects / correct_problems_sum
print(f'랜덤 시드: {seed_string}')
print(f'{len(participants)}명 {list(participants.keys())}')
# print(f'맞은 문제 개수: {list(participants.values())}')
# print(f'확률: {winner_percent}')
# 당첨자
winner = np.random.choice(list(participants.keys()), winner_num, replace = False, p = winner_percent) \
if winner_num < len(participants) else list(participants.keys())
winner.sort()
print(f'당첨자: {winner}')# your code goes here