VirtualCF
A Codeforces parser for a specific contest identified by contest-id. Can be used for uninterrupted and smooth participation in a virtual contest, upsolving a practice contest or even a live contest.
Inspiration
Python is the "most powerful language you can still read".
What it does
- You are prompted the contest-id of the Codeforces contest you want to upsolve
- You enter the contest-id
- You are prompted for the preferred coding language from a list of options
- You enter the option no.
- The script starts scraping the desired contest
- A Folder is created having the format ( name-of-the-contest)
- Each folder has individual folders for each problem (A to F)
- Each such sub-folder has 3 files (Assuming the problem is A)
- A.cpp (Assuming you code in cpp)
- A.txt (The i/o file)
- input.txt
- Each such sub-folder has 3 files (Assuming the problem is A)
- A stats.txt and a stats.png file is also created having showing the problem vs accepted ratio.It helps the user gauge the difficulty of each problem and the contest as a whole.
- Each folder has individual folders for each problem (A to F)
What to do
- Star the repo and clone it.
- Download all the files in a zip
- Install latest version of python (add to PATH) if not already installed
- Pip install all the below mentioned modules and dependencies
Edit: Make sure python3 is installed. pip3 will be more favourable after reports from various users.
- Place the script in a folder where you want the folder of the contest
- Place your code template inside the template.txt file
- Run python3 vir.py or python vir.py as suitable
- Bonus - If you place it in a git initialised repository, after the script finishes, you can simply commit all the changes and all your contest-codes will be pushed to github
- An active internet connection while the script parses
Youtube demo
The contest we want to participate in
Starter code to be placed in template.txt (I have used my personal template in repo)
int main() {
// your code goes here
freopen("input.txt", "r" , stdin);
return 0;
}
The highlighted part is the contest-id
Script prompting for contest-id and the preferred language choice
Start of file parsing ( has created the contest-folder)
Middle of parsing (inside the parent folder.. A problem has been scraped )
Middle of parsing (inside the parent folder.. B problem has been scraped )
Middle of parsing (inside the parent folder.. F problem has also been scraped )
Stats.png and stats.txt has been generated
stats.png
Peek inside the directory structure of a contest
A.txt
A.cpp (with a generic starter file)
Some users may encounter a https error. Here's the walkthrough.
You need to change all the https to http and delete the argument verify = True from every get request.
The highlighted parts show the https and verify=True clauses. They need to be dealt with as described above the pic.
Requirements
-
Modules
- os
- sys
- requests
- re
- bs4 (BeautifulSoup)
- time
- matplotlib
-
User Requiremets
- codeforces-contest-id of any contest
-
Python Version
- 3 or above
-
Active internet when py - script runs
-
The terminal (required for input) shows log as the script runs