This repository was created to test the capabilities of OpenCode and is for learning purposes only.
A local LeetCode-style coding challenge platform supporting Python and Kotlin. Solve algorithm problems in a web editor, run code against test cases on a local server, and get instant feedback.
pip install flask
python3 python/app.pyOpen http://127.0.0.1:5000 in your browser.
Tip: Press
Ctrl+Enter(orCmd+Enteron Mac) to run code without clicking the button.
To solve challenges in Kotlin, install the Kotlin compiler. Choose your language from the dropdown in the editor toolbar — the server will use kotlinc + java -jar to compile and run.
- Push this repo to GitHub
- Go to dashboard.render.com/blueprints
- Click New Blueprint and connect your repo
- The included
render.yamlandDockerfilewill automatically build and deploy - The site is live at https://opencodeleet.onrender.com/
Note: Render's free tier spins down after 15 min of inactivity. First request after idle takes ~30s to wake up.
- Dual language support — switch between Python and Kotlin per challenge, code saved independently per language
- Code editor with syntax highlighting, line numbers, bracket matching (CodeMirror with Dracula theme)
- Server-side execution in an isolated subprocess with a configurable timeout (default 3s)
- Test result parsing — results extracted from stdout markers (
ALL_TESTS_PASSED,TEST_FAILED:,ERROR:) - Solution unlock — after 3 failed attempts on a challenge, a reference solution is revealed
- Execution timing — elapsed time displayed per run in milliseconds
- Auto-save — code persisted to
localStorageper challenge per language, survives page reloads - Error line highlighting — error locations shown in the editor gutter and scrolled into view
- Difficulty-based sidebar — challenges grouped by Easy / Medium / Hard with color-coded badges
python3 python/test_app.py- Create a new
.pyfile inchallenges/(e.g.,challenges/my-challenge.py) - Define a
CHALLENGEdict with the keys below - Restart the server — the loader picks up new files automatically
| Key | Description |
|---|---|
id |
URL-safe slug (e.g., "my-challenge") |
title |
Display name (e.g., "1. My Challenge") |
difficulty |
"Easy", "Medium", or "Hard" |
description |
HTML string describing the problem |
starter_code |
Dict keyed by language — initial code the user sees |
solution_code |
Dict keyed by language — reference solution (unlocked after 3 fails) |
test_code |
Dict keyed by language — assertion harness that prints stdout markers |
Each language entry must contain complete, runnable code that prints one of these markers:
ALL_TESTS_PASSEDTEST_FAILED: <message>ERROR: <message>
| # | Challenge | Solution |
|---|---|---|
| 1 | Two Sum | Hash Map |
| 2 | Reverse String | Two Pointers |
| 3 | Palindrome Number | Math |
| 4 | Valid Parentheses | Stack |
| 5 | Contains Duplicate | Hash Set |
| 6 | Maximum Subarray | Kadane's Algorithm |
| 7 | Move Zeroes | Two Pointers |
| 8 | Best Time to Buy and Sell Stock | Greedy |
| 9 | Climbing Stairs | Fibonacci DP |
| 10 | Single Number | XOR |
| 11 | Missing Number | XOR / Math |
| 12 | First Unique Character in a String | Hash Map |
| 13 | Roman to Integer | Hash Map |
| 14 | Longest Common Prefix | Horizontal Scan |
| 15 | Plus One | Math |
| 16 | Power of Three | Math |
| 17 | Fizz Buzz | Simulation |
| 18 | Add Binary | Math |
| 19 | Pascals Triangle | DP |
| 20 | Remove Duplicates from Sorted Array | Two Pointers |
| 21 | Sqrt(x) | Binary Search |
| 22 | Happy Number | Hash Set / Cycle Detection |
| 23 | Intersection of Two Arrays | Hash Set |
| 24 | Majority Element | Boyer-Moore Voting |
| # | Challenge | Solution |
|---|---|---|
| 1 | Longest Substring Without Repeating Characters | Sliding Window |
| 2 | Three Sum | Two Pointers |
| 3 | Group Anagrams | Hash Map |
| 4 | Longest Palindromic Substring | Expand Around Center |
| 5 | Container With Most Water | Two Pointers |
| 6 | Product of Array Except Self | Prefix/Suffix |
| 7 | Coin Change | DP |
| 8 | Longest Increasing Subsequence | Patience Sorting |
| 9 | Set Matrix Zeroes | In-Place Markers |
| 10 | Rotate Image | Transpose + Reverse |
| 11 | Spiral Matrix | Boundary Traversal |
| 12 | Jump Game | Greedy |
| 13 | Unique Paths | DP |
| 14 | Word Search | DFS / Backtracking |
| 15 | Top K Frequent Elements | Hash Map + Heap |
| 16 | Sort Colors | Dutch Flag |
| 17 | Find the Duplicate Number | Floyd's Cycle |
| 18 | House Robber | DP |
| 19 | Binary Tree Level Order Traversal | BFS |
| 20 | Number of Islands | DFS |
| 21 | Subarray Sum Equals K | Prefix Sum + Hash Map |
| 22 | Find All Anagrams in a String | Sliding Window |
| 23 | Decode Ways | DP |
| # | Challenge | Solution |
|---|---|---|
| 1 | Trapping Rain Water | Two Pointers |
| 2 | First Missing Positive | Cycle Sort |
| 3 | Median of Two Sorted Arrays | Binary Search |
| 4 | Sliding Window Maximum | Deque |
| 5 | Merge k Sorted Lists | Min-Heap |
| 6 | Largest Rectangle in Histogram | Stack |
| 7 | Longest Valid Parentheses | Stack / DP |
| 8 | Edit Distance | DP |
| 9 | Minimum Window Substring | Sliding Window |
| 10 | Maximal Rectangle | Stack |
| 11 | Candy | Two-Pass Greedy |
| 12 | Word Ladder | BFS |
Dockerfile Container image (Python 3.11 + JDK 17 + Kotlin 2.1)
render.yaml Render Blueprint config for one-click deploy
requirements.txt Python dependencies (Flask)
challenges/ 60 .py files — one per challenge (auto-imported)
python/
├── app.py Flask routes and server entrypoint
├── loader.py Auto-imports challenge files, strips title numbers
├── config.py App constants (timeout, host, port, version)
├── runner.py Subprocess execution engine (Python + Kotlin)
├── test_app.py Unit tests (16 tests)
└── templates/
└── index.html Single-page frontend (Tailwind, CodeMirror, language switcher)
| Layer | Technology |
|---|---|
| Backend | Python, Flask |
| Frontend | Tailwind CSS, CodeMirror 5, FontAwesome |
| Languages | Python (built-in), Kotlin (requires kotlinc) |
| Testing | unittest |
| Execution | Subprocess with 3s timeout |
| Solution Reveal | After 3 failed attempts per challenge per language |
This project is for educational purposes. Challenge problems are sourced from LeetCode.
