Open In App

Project Idea | CodePal

Description: “A Visual Studio Code Extension to help Codeforces Users Code with Convenience”

CodePal is a Visual Studio Code Extension to help Codeforces Users Code with Convenience. This extension is especially for people who want to save time in a live Codeforces contest and up-solve problems comfortably. This extension responds quickly to users. It can swiftly filter through the problem list by specifying tags and ratings, create folders for contests and problems containing sample tests of each problem in them and compile and run tests automatically. For added convenience, we’ve created buttons to directly open problem statements and submission pages on the default browser.



Brief Overview of Technologies Used:

NodeJS



 

Codeforces API

TypeScript

VS Code API

Demo: Enter Handle in settings and view problems, contests, and profile, with submission status on each problem.

Create Problem/Contest Folders inclusive of all sample tests, compile and run automatically, get comprehensive verdicts, and view problem statement and submission webpages.

 

Filter Through Problems:

Stress Testing your Code:

Features of the Extension and Their Implementation Details

View Complete Problem Set List along with their associated tags and ratings: The list of problems along with their details are available through the Codeforces API. A problem class is maintained which is initialized by fetching details of all problems from this API end point. The fetched list of problems is displayed in a tree view in the activity bar on the left-hand side of the window.

Swiftly Filter through the ProblemSet by specifying Ratings, Tags, and Submission Status: The list of problems that are rendered in the tree view are filtered internally based on the problem tags, problem rating range, and submission status and re-rendered on the screen. The input for the filters is taken through the VS Code API.

View Currently Running, Upcoming and all Past Contests and also view the precise start date, time, and duration of upcoming contests: The list of contests along with their details are available through the Codeforces API. A contest class is maintained by us which is initialized by fetching details of all contests from this API end point. The list of contests is also displayed in a tree view on the activity bar on the left-hand side of the window.

Fast Folder Creation on a single click for Contests from the Codeforces contest list and Problems from the Codeforces problem list: When a user wishes to create a folder for a problem on Codeforces, a folder with the name of the problem is created and test cases of the particular problem are web scraped from the problem’s web page and are included in the same folder.  

When a user wishes to create a contest folder, a folder with the name of the contest is created, and a folder for each problem in the contest is iteratively created.

Folder for a problem consists of all its sample test cases and a program file loaded with a template whose path may be specified in the settings: What is also included in a problem folder is a file named as “Problem_name.{extension}” which loads any starter template that you like if you specify the template path in the settings of the extension.

Add additional tests to any problem: 2 Additional files called “input_{test_number}.txt” and “output_{test_number}.txt” are created where the user may enter the input he wants and the expected output respectively.

Compile and run any program file against the test cases and get comprehensive results: The *child_process* library is used to run compilation and running commands on the host’s system. We make sure to terminate a running program process in case it exceeds 6 seconds of execution. We measure the time by using races of promises in JavaScript. We set a timeout of 6 seconds and also run the program and whichever promise accepts or rejects first ends the wait and then the running program is terminated. This is very crucial to indicate “Time Limit Exceeded” to users.

The code is run on each of the sample test cases that are already present in the problem folder, and for each test a file is created having the output produced by the code, which is compared with the expected output file to give the verdict. A file called “result.txt” is created, having all details of each of the tests, including the input, expected output, obtained output and standard error, along with the final verdict on the test. In case of a compilation error or a run-time error, the error is logged into a file called “error.txt”.

Open problem statement or submission page on your default browser, with a single click in VS Code: A file is saved called “.problem.json” in the same directory as the problem file. This json file contains the problem index and the ID of the contest it was part of, details sufficient to construct the problem URL. So when a user clicks the “open problem statement” button, we construct the URL with the help of the json file and open it in your default browser. Similarly, the problem submission page can also be opened.

Compiler may be selected and compilation flags can be set through the codepal settings: Commands are run to compile and run the programs written by the user on his/her own system. They are compiled and run based on the language that has been selected from the CodePal settings. We also allow for additional compilation flags that a user may want to add. We add these flags to the command for compiling. Example: “-std=c++14”

Perform Stress Testing to find a counter test case for your code: We create 2 more files for the user

Now, we run the generator file and create test cases, and iteratively run both, the user’s code and the program file that he entered, against the generated test cases as many times as the user wants. They may specify the number of times he wants this to continue in the settings. This shall either stop as soon output given by the user’s code and the program file differ.

Get a personalized experience of viewing details of your Codeforces profile and the status of problem submissions made, by entering your Codeforces handle in the codepal settings: Given the handle of a user, the codeforces API can return basic information about the user. We present that in the user profile section. The codeforces API also returns the set of all submissions made by a given user. We sort submissions as per problem id, and then run a pointer each across the user’s submissions and problems (which are already sorted as per problem id) and determine the submission status of a problem (Passed, Failed, Unattempted).

Languages Supported:

Note: You may add additional compilation flags through the codepal settings (example: -std=c++14) and also choose between python, python2, or python3 depending upon the python command you use on your system to run.

Operating Systems Supported:

Keyboard Shortcuts:

Conclusion: Building a VS Code extension is a great way to understand how such a popular code editor like VS Code works. Also, this extension helps the community of competitive programming.

Team Members


Article Tags :