Created
September 9, 2024 08:51
-
-
Save roeniss/bb04866423964fef28fa85516fdd4588 to your computer and use it in GitHub Desktop.
solved ac api usage
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
#!/bin/bash | |
echo '' > problemToLevel.csv | |
result=$(seq 1 35000 | paste -sd "," - | sed 's/\([^,]*,\)\{100\}/&\n/g') | |
IFS=$'\n' read -rd '' -a number_array <<< "$result" | |
for i in "${!number_array[@]}"; do | |
number_array[$i]=${number_array[$i]%?} # remove last comma | |
echo "Processing $((i+1))th group..." | |
response=$(curl -s --request GET \ | |
--url "https://solved.ac/api/v3/problem/lookup?problemIds=${number_array[$i]}" \ | |
--header 'Accept: application/json' --header 'x-solvedac-language: ko') | |
echo $response | jq -r '.[] | "\(.problemId),\(.level)"' >> problemToLevel.csv | |
sleep 5 | |
done | |
echo "Done." | |
# 문제 난이도 표 (ref: https://solvedac.github.io/unofficial-documentation/#/operations/getProblemsCountGroupByLevel) | |
# 수치 이름 | |
# 0 Unrated / Not Ratable | |
# 1 Bronze V | |
# 2 Bronze IV | |
# 3 Bronze III | |
# 4 Bronze II | |
# 5 Bronze I | |
# 6 Silver V | |
# 7 Silver IV | |
# 8 Silver III | |
# 9 Silver II | |
# 10 Silver I | |
# 11 Gold V | |
# 12 Gold IV | |
# 13 Gold III | |
# 14 Gold II | |
# 15 Gold I | |
# 16 Platinum V | |
# 17 Platinum IV | |
# 18 Platinum III | |
# 19 Platinum II | |
# 20 Platinum I | |
# 21 Diamond V | |
# 22 Diamond IV | |
# 23 Diamond III | |
# 24 Diamond II | |
# 25 Diamond I | |
# 26 Ruby V | |
# 27 Ruby IV | |
# 28 Ruby III | |
# 29 Ruby II | |
# 30 Ruby I |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment