Skip to content

Instantly share code, notes, and snippets.

@tau0
Last active April 29, 2024 18:44
Show Gist options
  • Save tau0/3022c553bbc6f9eb395bb614cb73e994 to your computer and use it in GitHub Desktop.
Save tau0/3022c553bbc6f9eb395bb614cb73e994 to your computer and use it in GitHub Desktop.
tags distribution for codeforses
import json
import operator
# Original version by tau0 and st3v3n on codeforces
# Go the URL below on your browser and download the file to the same directory as this script
# https://codeforces.com/api/problemset.problems
data = json.load(open("/Users/tau0/Downloads/problemset.problems.json"))
counter = dict()
problems = data["result"]["problems"]
for problem in problems:
if "tags" in problem:
for tag in problem["tags"]:
if not tag in counter:
counter[tag] = 0
counter[tag] += 1
sorted_x = sorted(counter.items(), key=operator.itemgetter(1), reverse=True)
for line in sorted_x:
tag_name = line[0]
tag_name_escaped = tag_name.replace(" ", "+")
link = f"/problemset?tags={tag_name_escaped}"
value = line[1]
print(f" - [{tag_name}] ({link}) {value}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment