Skip to content

Problem & Exercise System

dagustin415 edited this page Feb 12, 2026 · 3 revisions

Problem & Exercise System

Problem System (/lib/problems/)

Overview

The problem system provides coding challenges across 25 programming languages. Each language has its own data file with problems following the Problem interface.

Structure

lib/problems/
├── index.ts              # Registry + query functions
├── javascript.ts         # JavaScript problems
├── typescript.ts         # TypeScript problems
├── python.ts             # Python problems
├── java.ts, cpp.ts, ...  # 21 more language files
└── interview-recommended.ts  # Curated interview-essential IDs
   └── Selective filtering: 14 core pattern categories, excludes hard difficulty

Query Functions

getProblemsForLanguage(lang)      // All problems for a language
getProblemsByCategory(lang, cat)  // Filter by category
getProblemsByDifficulty(lang, d)  // Filter by difficulty
getCategoriesForLanguage(lang)    // Available categories
getRandomProblem(lang)            // Random problem
searchProblemsByTag(lang, tag)    // Search by tag
getProblemCountByLanguage()       // Counts per language

Validation Strategies

JavaScript / TypeScript: Actual code execution via codeRunner.ts:

  • Function() constructor sandboxing with timeout
  • Anti-cheat detection (hardcoded output, no method usage, forbidden patterns)
  • Deep equality comparison for test case validation

All other languages: Pattern-based validation via validPatterns:

  • Each problem defines regex patterns the answer must match
  • Validates that the user's code contains the expected syntax/methods
  • Cannot verify actual execution (no in-browser runtime for Python, Java, etc.)

Anti-Cheat System (codeRunner.ts)

  • Detects hardcoded output (return value matches expected without computation)
  • Checks for required method usage
  • Blocks forbidden patterns
  • Hidden test cases for additional validation
  • Helpful error hints (15+ patterns mapping common errors to friendly messages)

Exercise System (/lib/exercises/)

Overview

"Building Blocks" exercises provide structured algorithm learning with starter code, test cases, and interactive visualizations.

Structure

lib/exercises/
├── types.ts              # Exercise types & display configs
├── javascript.ts         # JS exercises
├── typescript.ts         # TS exercises
├── python.ts             # Python exercises
├── javascript-extra.ts   # Additional JS exercises
├── typescript-extra.ts   # Additional TS exercises
└── tutor-prompt.ts       # AI tutor system prompt

8 Exercise Categories

Category Description
traversal Tree/graph traversal algorithms
iteration-patterns Loops, sliding window, two pointers
recursion Recursive algorithms
combinatorics Permutations, combinations, subsets
searching Binary search, DFS, BFS
data-structures Stacks, queues, heaps, tries
memoization Dynamic programming
utilities Helper functions and patterns

Exercise Features

  • Learn tab: Explanation + AI tutor (WebLLM)
  • Practice tab: Monaco Editor + test runner
  • Visualization: Lazy-loaded step-through animation (100+ visualizations)
  • Test runner: In-browser execution with pass/fail feedback

Quiz System

Method Quiz (/lib/problems.ts)

Multiple-choice questions about language methods/APIs. Generated from method data with auto-generated distractor options.

Algorithm Pattern Quiz (/lib/algorithmPatterns.ts)

170 algorithm pattern recognition problems. User reads a problem description and identifies which algorithm pattern to use.

50+ patterns including: Two Pointers, Sliding Window, Binary Search, BFS, DFS, Dynamic Programming, Backtracking, Greedy, Divide and Conquer, Topological Sort, Union Find, Trie, Heap, Stack, etc.

Complexity Quiz (/lib/complexityProblems.ts)

Time/space complexity questions. 10 categories with auto-generated distractor options from a standard complexities pool.

Regex Trainer (/lib/regexTrainer/)

Structure

lib/regexTrainer/
├── index.ts      # Public API
├── types.ts      # Types
├── problems.ts   # Regex problems
├── matcher.ts    # Evaluation engine
└── cheatsheet.ts # Regex reference data

7 Categories

Character Classes, Quantifiers, Anchors, Groups & Alternation, Lookaround, Common Patterns, Escaping & Special

How It Works

  1. User sees a text block with target matches highlighted
  2. User writes a regex pattern
  3. evaluateRegex() computes correct matches, false positives, missed matches
  4. Feedback shows precision/recall of the regex

Interview System (/lib/interview/)

Content

  • 72 algorithm problems across 22 patterns
  • 28 system design questions
  • Progressive hint system (4 escalation levels)
  • Frontend drill problems with selective Interview Recommended filter (8 core categories, excludes hard difficulty)

Features

  • InterviewConfig with adaptive difficulty
  • Conversation management for multi-turn AI interaction
  • Prompt engineering optimized for token efficiency (~30% reduction)
  • WebLLM (local) or OpenAI (cloud) for AI responses
  • Curated Interview Recommended selection (14 core algorithm patterns, 8 core frontend categories, hard difficulty excluded)

Clone this wiki locally