Блог пользователя Gediminas

Автор Gediminas, история, 7 лет назад, По-английски

Hello! It's the end of the year and I have a lot of free time so I decided to play with CF api and create some statistical tables. (Sorry for mistakes)
In 2017 CF hosted 151 official contests, 106 of them were rated. Each rated contest on average attracted 2700 participants.
Currently there are 121957 rated users. In 2017 about 20000 users joined this amazing community! 372 of them now are in Div. 1. We have:

Rank#%
newbies1321910,84%
pupils4349635,67%
specialists4136833,92%
experts1725114,15%
candidate masters53774,41%
masters5270,43%
international masters3020,25%
grandmasters2670,22%
international grandmasters1230,10%
legendary grandmasters270,02%
Thanks for MikeMirzayanov for maintaining this site!
And happy New Year!

  • Проголосовать: нравится
  • +45
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Nice job, Sir!

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Hi I believe that your statistics are wrong! A lot of people became legendary grandmasters today for no reason and no one knows it why, maybe Magic? At least 10% is legendary grandmaster today.

»
7 лет назад, # |
  Проголосовать: нравится -6 Проголосовать: не нравится

I hate pupils

»
7 лет назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

My Python 3 code to do queries:

import requests, hashlib, time, random, string, urllib, collections, json
import pickle, os.path
import sys, time
from time import sleep

class CFApi:
	key = 'ApiKey'
	secret = 'ApiSecret'
	apiurl = '//codeforces.com/api/'

	def CreateUrl(method, parameters = {}):
		seed = ''.join(random.choice(string.ascii_lowercase) for x in range(6))
		parameters['apiKey'] = CFApi.key
		parameters['time'] = str(int(time.time()))
		parameters['lang'] = 'en'
		param = collections.OrderedDict(sorted(parameters.items()))
		parameters['apiSig'] = seed + hashlib.sha512((seed+'/'+method + '?' + urllib.parse.urlencode(param)+'#'+CFApi.secret).encode()).hexdigest()
		return CFApi.apiurl + method + '?' + urllib.parse.urlencode(parameters)

	def GetJsonResult(method, parameters={}):
		try:
			t = (requests.get(CFApi.CreateUrl(method, parameters))).json()
			CFApi.lastcall = time.time()
			if t['status']!='OK':
				print(t)
				return None
			r = t['result']
			return r
		except Exception as e:
			print('{}: {}'.format(e.__class__.__name__, e), file=sys.stderr)
#Usage:
contests = CFApi.GetJsonResult('contest.list', {'gym': 'false'})