Facebook
From P.Alizadeh, 4 Years ago, written in Python.
Embed
Download Paste or View Raw
Hits: 758
  1. import requests
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4.  
  5.  
  6. cf = "http://codeforces.com/api/"
  7.  
  8.  
  9. def call(method, params):
  10.     url = f"{cf}{method}"
  11.     req = requests.get(url, params=params)
  12.     if req.status_code == 200:
  13.         return req.json()
  14.  
  15.  
  16. """
  17. Some Contests' id:
  18.    Good Bye 2019 : 1270
  19.    Edu 79        : 1279
  20.    Global 6      : 1266
  21.    Div3 #611     : 1283
  22.    Div2 #608     : 1271
  23.    Div1 #609     : 1268
  24.    Codefest 19   : 1208
  25. """
  26.  
  27. rating = [[1200, "gray"],
  28.           [1400, "green"],
  29.           [1600, "#03a89e"],
  30.           [1900, "blue"],
  31.           [2100, "#aa00aa"],
  32.           [2400, "orange"],
  33.           [3000, "red"],
  34.           [9999, "black"]]
  35.  
  36. data = call("contest.ratingChanges", {"contestId": "1283"})["result"]
  37. title = data[0]["contestName"]
  38. print(title)
  39.  
  40. delta = np.zeros((len(data),), dtype=np.int64)
  41. x = np.zeros((len(data),), dtype=np.int64)
  42. color = []
  43. for i in range(len(data)):
  44.     delta[i] = data[i]["newRating"] - data[i]["oldRating"]
  45.     x[i] = data[i]["rank"]
  46.     for j in range(len(rating)):
  47.         if data[i]["oldRating"] < rating[j][0]:
  48.             color.append(rating[j][1])
  49.             break
  50.  
  51. plt.figure(figsize=(8, 6))
  52. plt.title(title)
  53. plt.xlabel("Rank")
  54. plt.ylabel("Delta Rate")
  55. plt.yticks(np.arange(-300, 301, 50))
  56. plt.ylim(-300, 300)
  57. plt.grid()
  58. plt.scatter(x, delta, s=0.5, c=color)
  59. plt.show()
  60.  

Replies to RankVsDelta rss

Title Name Language When
Re: RankVsDelta Stained Gorilla python 3 Years ago.
Re: RankVsDelta Cute Stork python 4 Years ago.
Re: RankVsDelta Thundering Pelican python 4 Years ago.
Re: RankVsDelta Crimson Moth python 4 Years ago.
Re: RankVsDelta Gray Stork python 4 Years ago.