Problems / Writing Code for a Problem

Writing Code for a Problem

How This Page Works

  1. Title block: sheet number, difficulty, format, mode and sub-topics
  2. The statement, in sections you can open and close
  3. Need a Hint?: each hint states its cost before you take it
  4. The config editor, with errors marked as you type
  5. Run: runs your answer, then the server checks it
  6. The terminal: what your code prints, and whether it ran
  7. The results: what your config did, turn by turn
  8. Your result, against the pass and full-points lines
  9. Flag a Problem: report anything wrong

On the tutorials, these numbers appear beside the real parts of the page.

1
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.

Go to the Editor Need a Hint?

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.

  1. The title block lists the sheet number, difficulty, format and mode.
  2. Open and close each section of this statement with its bar.
  3. The hint below is free here, unlike on real problems.
  4. Edit support.py in the editor marked 4.
  5. Press Run. Your code runs in your browser, then the server checks it.
  6. The terminal shows what your code prints, and whether it ran or stopped on an error.
  7. The results show each answer, your code's model calls, and their cost.
  8. The first line of the results shows your cost cut against the pass line and the full-points line.
  9. 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:

Prices by model, in dollars per million tokens
ModelInputOutput
large525
medium315
small15

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.

4support.py
5 Runs your code on 3 inputs in your browser, then the server checks the results. Tab indents; press Escape, then Tab, to leave the editor. Ctrl+Enter runs.

6Output

terminal
$ python support.pyPress Run to start.
9Something wrong with this problem?

Flag a Problem

Sign in to flag this problem. Reports help fix wording, checks and pages.

Sign In

Reports go to the site owner. Privacy

9Something wrong with this problem?

Flag a Problem

Sign in to flag this problem. Reports help fix wording, checks and pages.

Sign In

Reports go to the site owner. Privacy