import numpy as np
import hashlib
# 추첨 인원수
winner_num = 3
# BOJ 연습란을 텍스트로 긁어오면 됩니다 (랭킹, 아이디, A, B, C, ... 맨 윗줄 제외하고)
info = """
3 bwgreen 3 / 999 1 / 960 2 / 1087 2 / 1099 1 / 1092 5 / 1291 1 / 2214 7 / 8742
4 glnthd02 3 / 2040 1 / 2358 1 / 3100 3 / 3788 3 / 3194 2 / 3825 1 / 4248 7 / 22553
5 codingstarfish 1 / 3966 1 / 3972 2 / 4005 1 / 4009 2 / 4042 1 / 4332 3 / 4417 7 / 28743
6 haerizian 2 / 1566 1 / 1683 1 / 1714 3 / 2811 2 / 2830 2 / 3073 10 / -- 6 / 13677
7 hms0510 2 / 1528 1 / 1293 1 / 2341 4 / 2662 2 / 3033 4 / 3012 0 / -- 6 / 13869
8 choiseoo 1 / 1316 1 / 1359 1 / 1519 1 / 2838 2 / 2888 0 / -- 0 / -- 5 / 9920
9 jung0722 1 / 3908 1 / 3930 1 / 3948 1 / 3992 1 / 4036 0 / -- 0 / -- 5 / 19814
10 psh030122 2 / 2295 1 / 2292 4 / 2701 1 / 5391 0 / -- 0 / -- 0 / -- 4 / 12679
11 bakbakwanwan 1 / 244 1 / 250 0 / -- 0 / -- 1 / 2670 0 / -- 0 / -- 3 / 3164
12 sjyoon1101 3 / 1273 1 / 1257 1 / 1458 8 / -- 0 / -- 0 / -- 0 / -- 3 / 3988
13 ansinbin000 1 / 1257 1 / 1283 3 / 1620 1 / -- 0 / -- 0 / -- 0 / -- 3 / 4160
14 upncol 0 / -- 0 / -- 0 / -- 2 / 4484 5 / 4703 1 / 4585 0 / -- 3 / 13772
15 gandori3 1 / 8305 1 / 8309 3 / -- 0 / -- 0 / -- 1 / 8101 0 / -- 3 / 24715
16 kelvin3596 2 / 8458 1 / 8440 2 / 8506 0 / -- 0 / -- 0 / -- 0 / -- 3 / 25404
17 osskch1 1 / 1297 1 / 1307 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 2 / 2604
18 yuujeong0816 1 / 5567 1 / 6953 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 2 / 12520
19 aarhrl2 0 / -- 0 / -- 0 / -- 1 / 5195 2 / 8359 0 / -- 0 / -- 2 / 13554
20 kdy06 1 / 8460 1 / 8489 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 2 / 16949
21 chipi2302 2 / 1596 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 1 / 1596
22 haein0684 1 / 6019 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 1 / 6019
"""
info = info.splitlines(keepends = True)
if info[0] == "\n": info.pop(0)
# 랜덤 시드
mod = 4294967296 # 2^32
seed_string = "250909"
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