import numpy as np
import hashlib
# 추첨 인원수
winner_num = 5
# BOJ 연습란을 텍스트로 긁어오면 됩니다 (랭킹, 아이디, A, B, C, ... 맨 윗줄 제외하고)
info = """
1 bwgreen 1 / 3 1 / 7 1 / 10 2 / 43 2 / 53 6 / 165 3 / 134 2 / 162 8 / 577
2 glnthd02 1 / 1474 2 / 1500 1 / 1490 2 / 1675 7 / 2103 4 / 1673 1 / 1892 1 / 7304 8 / 19111
3 hms0510 1 / 156 1 / 163 1 / 173 3 / 1576 3 / 1946 3 / 2854 4 / 6043 0 / -- 7 / 12911
4 kelvin3596 1 / 1980 1 / 1968 1 / 1946 3 / 1683 6 / 1788 12 / 2147 0 / -- 0 / -- 6 / 11512
5 gandori3 1 / 612 1 / 619 1 / 625 1 / 2765 2 / 3439 5 / 3543 0 / -- 0 / -- 6 / 11603
6 rlawoaks 1 / 71 2 / 108 3 / 318 5 / 5984 18 / 6340 0 / -- 0 / -- 0 / -- 5 / 12821
7 chipi2302 1 / 2097 1 / 3451 1 / 4894 1 / 6335 5 / 7356 0 / -- 0 / -- 0 / -- 5 / 24133
8 yuujeong0816 1 / 165 1 / 181 1 / 235 4 / -- 7 / 4767 8 / -- 0 / -- 0 / -- 4 / 5348
9 dksalsdn0226 1 / 3090 1 / 3100 1 / 3109 5 / 3214 0 / -- 0 / -- 0 / -- 0 / -- 4 / 12513
10 bakbakwanwan 1 / 578 1 / 603 1 / 620 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 3 / 1801
11 jung0722 1 / 1572 1 / 1589 1 / 1607 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 3 / 4768
12 choiseoo 1 / 1711 5 / 1825 1 / 1769 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 3 / 5305
13 harrysooin 1 / 112 0 / -- 1 / 2749 1 / -- 0 / -- 0 / -- 0 / -- 0 / -- 2 / 2861
14 kdy06 1 / 1886 1 / 1916 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 2 / 3802
15 aerae 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 2 / 1913 0 / -- 2 / 3084 2 / 4997
16 psh030122 1 / 4385 0 / -- 1 / 6338 1 / -- 0 / -- 0 / -- 0 / -- 0 / -- 2 / 10723
17 aarhrl2 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 1 / 7300 9 / 8772 0 / -- 2 / 16072
18 ansinbin000 1 / 1633 1 / -- 0 / -- 1 / -- 0 / -- 0 / -- 0 / -- 0 / -- 1 / 1633
"""
info = info.splitlines(keepends = True)
if info[0] == "\n": info.pop(0)
# 랜덤 시드
mod = 4294967296 # 2^32
seed_string = "250922"
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','likescape']
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