-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathranking.py
69 lines (58 loc) · 1.76 KB
/
ranking.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 <@DESKTOP-TA60DPH>
#
# Distributed under terms of the MIT license.
# Auther : RB
import requests
import simplejson as json
from simplejson.compat import StringIO
"""
get the ranking between NTU on kaggle competition
"""
rank = requests.get("https://www.kaggle.com/c/8900/leaderboard.json?includeBeforeUser=false&includeAfterUser=true")
io = StringIO(rank.text)
data = json.load(io)
before = data["beforeUser"]
near = data["nearUser"]
after = data["afterUser"]
counter = 1
print(" ",format("rank","^6"),format('score',"^15"),format('teamName',"<30"))
for i in before:
our = ' '
if i['teamName'][:4] == "NTU_":
if i['teamName'] == "NTU_r06942018___":
our = '*'
position = counter
print('['+our+']',format(counter,"^6"),format(i['score'],"^15"),format(i['teamName'],"<30"))
counter+=1
for i in near:
our = ' '
if i['teamName'][:4] == "NTU_":
if i['teamName'] == "NTU_r06942018___":
our = '*'
position = counter
print('['+our+']',format(counter,"^6"),format(i['score'],"^15"),format(i['teamName'],"<30"))
counter+=1
for i in after:
our = ' '
if i['teamName'][:4] == "NTU_":
if i['teamName'] == "NTU_r06942018___":
our = '*'
position = counter
print('['+our+']',format(counter,"^6"),format(i['score'],"^15"),format(i['teamName'],"<30"))
counter+=1
if position < 10:
score = 2
if position < 8:
score = 5
if position < 6:
score = 7.5
if position < 4:
score = 10
print("")
print("Rank (in NTU) : ",position,"/ 10 ")
print("Ranking Point : ",score)
print("")