practice

Write the code. Pass the tests.

Every problem runs real Python in your browser and checks it against test cases, some of them hidden until you submit. Pick a track and work down it. Each one goes from easy to hard.

243 problems in 12 tracks

start here

Build an Agent, in 12 stages

You write the program behind every AI agent, one piece at a time, and each stage starts from the code of the stage before. The model is scripted, so your tests are exact. Stage 1 is right here: make the four visible cases pass, then submit to run the hidden ones.

Python3
import json
import math
import re


def parse_tool_call(text):
"""Return {"tool": str, "arguments": dict} for a tool call, None for a final answer.
Raise ValueError for a malformed tool call."""
# Your code here
pass

Test Cases
Case 1 — Bare JSON tool call
Input: {"text":"{\"tool\": \"get_weather\", \"arguments\": {\"city\": \"Paris\"}}"}
Expected: {"tool":"get_weather","arguments":{"city":"Paris"}}
Case 2 — Model thinks out loud before the JSON
Input: {"text":"Let me check the forecast first.\n{\"tool\": \"get_weather\", \"arguments\": {\"city\": \"Tokyo\"}}"}
Expected: {"tool":"get_weather","arguments":{"city":"Tokyo"}}
Case 3 — No tool call means a final answer
Input: {"text":"It is 18C and raining in Paris."}
Expected: null
Case 4 — JSON inside a ```json fence
Input: {"text":"Sure!\n```json\n{\"tool\": \"add\", \"arguments\": {\"a\": 2, \"b\": 3}}\n```"}
Expected: {"tool":"add","arguments":{"a":2,"b":3}}
  1. 01Parse a Tool Call From Model Output
  2. 02Validate Tool Arguments Against a Schema
  3. 03Dispatch Tool Calls Without Crashing the Agent
  4. 04The Agent Loop
  5. 05Recover From Malformed and Failing Tool Calls
  6. 06Guardrails: Loop Detection and Token Budgets
  7. 07Trim Context Without Orphaning Tool Results
  8. 08Parallel Tool Calls With IDs
  9. 09Long-Term Memory Recall
  10. 10Plan-and-Execute With Dependencies
  11. 11Evaluate Your Agent
  12. 12Capstone: A Production Agent Loop

All tracks

  1. 01Build an AgentWrite a tool-using agent from scratch, one piece per problem: parsing, dispatch, the loop, guardrails, memory, planning, evals.Intermediate
    12 problems
  2. 02Specify, Verify, DebugThe work left when an agent writes the code: turn requests into tests, debug production failures, measure LLM output, and decide what ships.Intermediate
    12 problems
  3. 03Python for AIThe everyday Python behind data and model code: dicts, nesting, text, caches and small parsers.Beginner
    19 problems
  4. 04NumPy & Data WranglingScaling, encoding, splitting and reshaping data the way training pipelines actually need it.Beginner
    18 problems
  5. 05Math for MLVectors, matrices, probability and optimisation, each implemented by hand so the formulas stop being abstract.Beginner
    18 problems
  6. 06Classical ML from ScratchRegression, trees, k-means, naive Bayes, SVMs and the metrics that tell you whether any of it worked.Intermediate
    21 problems
  7. 07Neural Networks by HandForward passes, backprop, optimisers, convolutions and recurrent cells, the pieces inside every framework.Intermediate
    24 problems
  8. 08Inside an LLMAttention, masks, positional encodings, sampling, the KV cache and the tricks that make inference fast.Intermediate
    22 problems
  9. 09RAG & RetrievalChunking, vector search, hybrid ranking, re-ranking and the checks that catch an ungrounded answer.Intermediate
    21 problems
  10. 10Agents in ProductionWhat surrounds the loop: MCP plumbing, caching, fallbacks, security checks, graphs and observability.Advanced
    24 problems
  11. 11ML Systems & MLOpsTraining schedules, drift, rollouts, experiments and the arithmetic of serving models.Advanced
    14 problems
  12. 12Coding Interview PatternsThe classic patterns interviews still test: hashing, two pointers, windows, stacks, trees, graphs and DP.Intermediate
    38 problems