import numpy as np
import hashlib
# 추첨 인원수
winner_num = 5
# BOJ 연습란을 텍스트로 긁어오면 됩니다 (랭킹, 아이디, A, B, C, ... 맨 윗줄 제외하고)
info = """
1 glnthd02 1 / 72 1 / 75 1 / 81 1 / 88 1 / 111 5 / 559 4 / 4287 7 / 5273
2 bwgreen 1 / 241 1 / 245 1 / 265 3 / 315 1 / 299 13 / 807 1 / 6267 7 / 8439
3 gandori3 1 / 3548 3 / 2185 2 / 3489 1 / 1669 3 / 3562 1 / 5620 6 / 4608 7 / 24681
4 dksalsdn0226 5 / 216 1 / 144 4 / 229 3 / 232 3 / 271 13 / 1507 0 / -- 6 / 2599
5 aarhrl2 2 / 5010 1 / 4972 1 / 4967 5 / 3186 5 / 3399 14 / 5159 0 / -- 6 / 26693
6 hms0510 1 / 155 1 / 161 1 / 185 2 / 243 2 / 517 0 / -- 0 / -- 5 / 1261
7 silhighver 1 / 3701 1 / 3709 0 / -- 1 / 3614 1 / 3677 3 / 4483 0 / -- 5 / 19184
8 jnn54 3 / 6007 1 / 5986 1 / 6013 1 / 6025 3 / 6391 0 / -- 0 / -- 5 / 30422
9 haerizian 2 / 6373 1 / 6360 1 / 6387 1 / 6401 1 / 6413 0 / -- 0 / -- 5 / 31934
10 bakbakwanwan 1 / 528 1 / 558 1 / 590 1 / 603 0 / -- 0 / -- 0 / -- 4 / 2279
11 sjyoon1101 2 / 422 1 / 431 1 / 510 3 / 1694 0 / -- 2 / -- 0 / -- 4 / 3057
12 psh030122 5 / 195 2 / 1529 1 / 1528 1 / 3070 0 / -- 0 / -- 0 / -- 4 / 6322
13 ansinbin000 3 / 4384 2 / 4492 1 / 4563 2 / 4628 0 / -- 0 / -- 0 / -- 4 / 18067
14 gebalsebal 3 / 3135 1 / 3105 0 / -- 3 / 3184 3 / -- 0 / -- 0 / -- 3 / 9424
15 yuujeong0816 1 / 6302 1 / 1979 1 / -- 1 / 1824 5 / -- 0 / -- 0 / -- 3 / 10105
16 harrysooin 2 / 3137 1 / 4757 2 / 5914 0 / -- 0 / -- 0 / -- 0 / -- 3 / 13808
17 choiseoo 2 / 1733 1 / 3188 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 2 / 4921
18 upncol 0 / -- 0 / -- 0 / -- 2 / 4143 6 / 4276 0 / -- 0 / -- 2 / 8419
19 kdy06 1 / 5798 2 / 6254 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 2 / 12052
20 aerae 0 / -- 1 / 37 2 / -- 0 / -- 0 / -- 0 / -- 0 / -- 1 / 37
21 jung0722 1 / 124 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 1 / 124
22 likescape 1 / 544 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 0 / -- 1 / 544
"""
info = info.splitlines(keepends = True)
if info[0] == "\n": info.pop(0)
# 랜덤 시드
mod = 4294967296 # 2^32
seed_string = "250917"
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