DEV Community

Shreshth Khetan
Shreshth Khetan

Posted on

Building an Un-Cheatable AI Mentor for Competitive Programming

Hacktoberfest Weekend Challenge: Build for a Friend Submission 🤝

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend

What I Built

Technical placement season is here, and a close friend of mine has been grinding data structures and algorithms for upcoming recruitment drives. But they hit a massive roadblock: standard AI chatbots are terrible teachers.

When they got stuck on a Dynamic Programming problem and asked for a hint, commercial AI tools just spat out the entire 50-line C++ solution. It ruined the learning process. My friend didn't want the answer; they wanted to build algorithmic intuition.

So for this challenge, I built them the Competitive Programming Hint Engine—a strict, Socratic AI mentor that is programmatically barred from writing code.

The CLI works seamlessly locally. You paste a problem description and where you are stuck, and it guides you without spoiling the solution.

Code

🧠 Competitive Programming Hint Engine

A strictly Socratic, 100% local AI mentor designed to help students master Data Structures and Algorithms without the temptation of copy-pasting code.

🌟 The "Why"

This project was built for the Hacktoberfest 2026 Weekend Challenge under the theme "Build for a Friend" When preparing for technical placements, the biggest trap students fall into is relying on AI to write the code for them. True learning happens when you struggle with the logic, not when you copy-paste the syntax. I built this tool for a friend to provide guidance, suggest data structures, and analyze time complexities—all while strictly refusing to write the actual implementation.

✨ Key Features

  • Socratic Mentorship: Analyzes your approach and asks guiding questions instead of spoon-feeding answers.
  • Constraint Pre-Parser: Automatically reads problem constraints (e.g., $10^5$) and suggests the target time complexity before passing context to the AI.
  • Regex Interceptor…

How I Built It

The CP Hint Engine is a local, CLI-based AI agent built in Python around an open-weight model (gemma2:2b or llama3.2:1b) running locally via Ollama.

It features a custom agent harness with two key components:

  1. Constraint Pre-Parser: It reads problem constraints using RegEx (e.g., $10^5$) and automatically suggests the target time complexity (e.g., $O(N \log N)$) before passing context to the LLM.
  2. The "Un-Cheatable" Harness Interceptor: To prevent the LLM from hallucinating and outputting code, I built a deterministic regex interceptor. If it detects a markdown code block in the LLM's output, it intercepts and replaces it with: > [Harness Intercept: Code generation blocked to preserve learning].

Why Does Open Innovation Matter?

Building this with open-source AI was the only way this project could succeed for three main reasons:

  1. Absolute Control: Commercial, closed-source APIs frequently ignore negative system instructions like "do not write code." By using an open-source model running locally, I could wrap it in a custom Python harness that gives me ultimate, programmatic control over the output. I own the intercept layer.
  2. Offline Capability: Campus Wi-Fi can be notoriously spotty. Running open-weight models locally means my friend can practice anywhere, completely offline.
  3. Privacy and Cost: Placement prep requires hundreds of problems. My friend can run this locally without worrying about API token limits, subscription costs, or sending their learning struggles to a corporate server.

My Agent Session

I mapped out the architecture and built the core regex harness alongside the Antigravity IDE assistant (using skills from the Google AI Agents intensive course).

Prize Categories

  • Best Use of Gemma

Top comments (0)