1. Get the task
Download the worksheet and create the two files in a new directory. The starter has an intentional defect: its tests should fail before a solution is made. It uses Node's built-in test runner, so there are no packages to install.
The task asks for a small correction to a token-cost function: price uncached and cached input at their separate documented rates, validate finite non-negative whole numbers, and reject cached input that exceeds total input.
Download worksheet2. Run and review it
- Run the starter tests and confirm that they fail as described.
- Use the included prompt with a tool you can access, or solve it yourself.
- Read the changed file and run the tests yourself.
- Treat a passing run as evidence only that this fixture's acceptance requirements were met.
3. Keep a local record
Optional fields help you retain your own setup and outcome. API token observations are exported as entered; subscription quota observations stay separate and are never converted to a dollar value.
GUIDED TRIAL · UNMEASURED
Record one small coding task
Run the intentionally failing starter, then review the result yourself. This worksheet is a repeatable practice task, not a model benchmark or a claim that this guide tested a model.
View task prompt
You are working in a tiny JavaScript fixture with Node's built-in node:test.
Implement src/total-cost.mjs so totalCost({ inputTokens, cachedInputTokens,
outputTokens }) returns the per-request USD token cost using these rates per
one million tokens: $4 for uncached input, $0.20 for cached input, and $20 for
output. Cached input is part of total input, so only inputTokens -
cachedInputTokens receives the uncached input rate.
Rules:
- inputTokens, cachedInputTokens, and outputTokens must each be finite,
non-negative whole numbers.
- cachedInputTokens must not exceed inputTokens.
- Throw a helpful Error when a rule is violated.
- Keep the public function name and input object shape unchanged.
- Add focused tests only if they add a distinct edge case.
- Run `node --test test/total-cost.test.mjs` and report the result.
Do not use external packages or change the task into a different project.