This repository contains a Python script, create_problem.py, that automates creating a folder and a starter code file for competitive programming problems from multiple sources:
- LeetCode (via
alfaarghya/alfa-leetcode-api) - Codeforces (via official API + HTML scraping for the full statement)
- VJudge (HTML scraping for problem statements)
- Custom (no external data, just create a folder and skeleton)
It supports C++, C, Python, and Java skeletons in either Minimal or Extended format.
-
LeetCode
- Automatically fetches the problem title, difficulty, and content via
alfaarghya/alfa-leetcode-api. - Important: The
alfaarghya/alfa-leetcode-apicode is Node.js/TypeScript and does not install as a Python library. You must either run its Node server and query it via HTTP or replicate the logic in Python. - If your LeetCode session cookie is invalid or not set up, the script prompts you gracefully, so it won’t crash.
- Automatically fetches the problem title, difficulty, and content via
-
Codeforces
- Fetches metadata (title, tags) from the official Codeforces API.
- Scrapes the actual problem statement HTML from
https://codeforces.com/contest/<contestId>/problem/<index>to include in your file comments.
-
VJudge
- Scrapes the problem statement from
https://vjudge.net/problem/<OJ>-<ProblemID>(e.g.,https://vjudge.net/problem/LightOJ-1000). - If any authentication is required, the script attempts to retrieve the public portion, or it will fallback gracefully.
- Scrapes the problem statement from
-
Custom
- No external calls; simply creates a folder with your chosen name.
-
Multiple Languages
- C++, C, Python, Java
- Additional skeleton logic for “Minimal” (bare-bones
main()) or “Extended” (class or function-based approach).
-
Automated Folder Creation
- Creates a folder named according to the problem source and ID, e.g.,
leetcode_p13,codeforces_p4A,vjudge_problem_lightoj1000, or your custom name.
- Creates a folder named according to the problem source and ID, e.g.,
-
Configurable Skeleton
- Extended skeleton can prompt for class/struct/function details.
- The script writes comments at the top of the file containing problem metadata or statement snippet.
(Optional but Recommended) Create and Activate a Python Virtual Environment
This helps avoid system-level Python issues (especially on Debian/Ubuntu with PEP 668).
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt