Problems / Writing Code for a Problem
Writing Code for a Problem
- Sheet
- T-04
- Difficulty
- Easy 1
- Format
- Code
- Mode
- Simulated
- Sub-topics
- Tutorial
Open this on a computer to solve it. Code problems need a wider screen.
2Edit Python in the browser, run it, and read its output and results.
The Situation
This tutorial shows how code problems work. A support bot for the Orbit 300 espresso machine answers customer questions from its manual. Your code is a short Python function: a named piece of code, here called answer. The page runs answer once for each question, and passes in llm, a helper: your code calls llm.complete to ask a model for a reply.
The starting code sends every question to the large model, for $0.0031. The small model can answer them all.
Your job: in support.py, change model="large" to model="small", then press Run.
Your Move
Each step's number matches a marker on the page.
These steps need a computer: a phone has no editor, so there’s nothing here to edit or run. Open this tutorial on a computer to follow them.
- The title block lists the sheet number, difficulty, format and mode.
- Open and close each section of this statement with its bar.
- The hint below is free here, unlike on real problems.
- Edit
support.pyin the editor marked 4. - Press Run. Your code runs in your browser, then the server checks it.
- The terminal shows what your code prints, and whether it ran or stopped on an error.
- The results show each answer, your code's model calls, and their cost.
- The first line of the results shows your cost cut against the pass line and the full-points line.
- If anything on a problem looks wrong, use Flag a Problem to tell us.
The Rule That Decides
R1. Models
Each question has a level: how hard it is. Each model has a level too: the hardest question it can answer. Large is 95, medium is 80, and small is 60. A model answers correctly when the question's level is at most the model's. Today's questions are levels 25 to 40.
Targets
- Cost cut: how much less your code costs than the starting code's $0.0031. The pass line is 50%, the least you need to pass. The full-points line is 75%, the cut that earns every point on a real problem.
- Accuracy: every question answered correctly (100%).
The Fine Print
R2. Prices
Models read and bill text in tokens, which are small pieces of words. Input is the text you send to the model. Output is the reply it writes back. Prices are in dollars per million tokens:
| Model | Input | Output |
|---|---|---|
| large | 5 | 25 |
| medium | 3 | 15 |
| small | 1 | 5 |
R3. Tokens
The model counts one input token for every 4 characters you send, rounded up. Every answer is 40 output tokens.
R4. Everything Else
- Levels run from 1 to 100.
- The server checks each answer against the manual's answer.
- In the editor, Tab indents your code. Press Escape, then Tab, to move out of the editor.
- A run stops after 30 seconds. Press Stop to end it sooner.
- The starting code prints each question, so you can see it in the terminal.
3Need a Hint?
Hints are free in tutorials.
$ python support.pyPress Run to start.