Last active
August 15, 2019 05:01
-
-
Save jin10086/71bf21a6bc7bd866c17ca537caa8fd2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
def get_winner(min_n, max_n, num_win, key): | |
res = key | |
winners = set() | |
while len(winners) < num_win: | |
res = hashlib.sha256(res.encode("utf8")).hexdigest() | |
winners.add(int(res, 16) % (max_n - min_n + 1) + min_n) | |
return winners | |
if __name__ == "__main__": | |
key = "00000000000000000006a4d492b3a4dcf63a0786900060e73d12e5bb30c4bc4d" | |
print(get_winner(0, 113, 3, key)) | |
#{113, 50, 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment