This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady
What I Built
Anyone who has solved Data Structures & Algorithms (DSA) problems on LeetCode, Codeforces, or GeeksforGeeks knows the two most tedious, energy-draining chores:
- Manually inventing tricky edge-case test inputs (empty structures, single elements, alternating signs, duplicate values, and $10^9$ boundary traps) when your code fails on a hidden test case.
- Dry-running code by hand on paper to calculate nested loop states and verify whether a solution is about to hit Time Limit Exceeded (TLE) or an integer overflow.
Meet CP Sloth 🦥 — a Manifest V3 Chrome Extension powered by Google's open-weight Gemma 3 (4B) model running locally via Ollama that channels pure developer laziness.
Instead of spending 10 to 15 minutes manually writing test cases or tracing pointer logic, you click a single "🦥 Do the Thinking" button in your browser toolbar while on any problem page. CP Sloth extracts the problem statement and constraints from your active browser tab, evaluates your pasted solution, and immediately produces:
- 5 Nasty, Copy-Pasteable Edge Cases: Boundary tests tailored directly to the problem's mathematical limits.
-
An Instant Complexity & TLE Verdict: Time and space complexity breakdown plus alerts for integer overflow traps (such as forgetting
long longin C++). - The Lazy Sloth Fix: A quick two-line architectural adjustment to optimize your approach with minimal effort.
Demo
How It Works in Action:
- Open any problem on LeetCode or Codeforces.
- Open CP Sloth from the toolbar and paste your draft code (or leave it blank to analyze constraints only).
- Click "🦥 Do the Thinking". Local Gemma 3 parses the DOM text, calculates potential bottleneck bounds, and renders the ready-to-use test inputs in 3 to 5 seconds.
Code
🦥 CP Sloth — Lazy DSA Edge-Case & TLE Analyzer
Automate the most exhausting part of LeetCode and Codeforces. Generate nasty boundary test cases and calculate algorithmic time/space bottlenecks in one click using local, open-weight AI.
📖 Overview
When solving Data Structures & Algorithms (DSA) problems, two repetitive chores drain time and momentum:
-
Manually inventing boundary test cases (single elements, duplicates, alternating negative integers, empty sets, or
$10^9$ limits) when a submission fails on an opaque test case. -
Dry-running logic on paper to detect whether an algorithm will trigger Time Limit Exceeded (TLE) or an integer overflow trap (e.g., omitting
long longin C++).
CP Sloth is a lightweight Manifest V3 Chrome Extension designed for peak developer laziness. With a single click while viewing any problem page, it extracts constraints directly from the tab's DOM and sends them to a locally hosted Google Gemma 3 (4B) model to evaluate bottlenecks…
Direct Link: https://github.com/Abhi7303/cp-sloth
The project is lightweight and zero-dependency:
-
manifest.json: Manifest V3 configuration withactiveTabandscriptingpermissions. -
popup.html: Minimalist dark-mode UI with clipboard-ready formatting. -
popup.js: Injects content capture scripts into the current tab and streams queries to the local Ollama daemon. -
icon.png: Custom sloth extension branding.
How I Built It
The entire stack is built around local open-weight AI and browser-native APIs:
-
The Brain (Google Gemma 3 - 4B): I selected
gemma3:4bbecause it delivers strong mathematical and coding reasoning at an accessible ~3.4 GB footprint. It effortlessly parses problem boundaries ($N \le 2 \times 10^5$) and identifies asymptotic complexity without requiring a high-end cloud cluster. -
Local Inference Engine (Ollama): The extension connects directly to
http://localhost:11434/api/generate. Running Ollama withOLLAMA_ORIGINS="*"enables cross-origin communication from the Chrome extension sandbox directly to Apple Metal hardware acceleration. -
Manifest V3 Tab Scraping: Using
chrome.scripting.executeScript, CP Sloth captures the active tab's textual context (document.body.innerText.slice(0, 4000)) directly from the problem page without requiring invasive background tracking scripts.
Why Does Open Innovation Matter?
Using an open-weight model running locally on consumer hardware completely outclasses closed cloud APIs for this use case:
- $0 Cost & Unlimited Iterations: Grinding through a 300-question DSA list involves testing dozens of solutions each day. Calling proprietary cloud APIs for every test run would rack up ongoing API bills or hit strict hourly rate limits. Running an open-weight model locally costs $0 forever.
- 100% Offline Capability: Students and developers frequently practice in classrooms, libraries, or transit commutes with unstable Wi-Fi. Because the model weights live on local storage, CP Sloth operates at full speed with zero internet connection.
-
Privacy & Ownership: Draft solutions, private contest submissions, and browser contexts never leave
localhost. There is zero telemetry and no corporate data harvesting. -
Model Flexibility: Because the inference layer connects to a standard Ollama endpoint, anyone can swap the backend to
qwen2.5-coderor a quantized1bmodel by altering a single string inpopup.js.
The Lazy Payoff
During testing on dynamic programming and sliding window problems this week, CP Sloth cut edge-case debugging time from 12 minutes down to under 5 seconds. It caught an off-by-one error on single-element arrays and warned about an $O(N^2)$ worst-case skew on an un-memoized recursion tree before hitting submit.
Prize Categories
-
Best Use of Gemma: CP Sloth is built around Google's open-weight Gemma 3 (
gemma3:4b) running locally on consumer hardware to automate algorithm evaluation, boundary analysis, and complexity estimation.


Top comments (0)