Retirement drawdown with a 4% rule, inflation raises and a skip-raise-after-loss guardrail
Exact prompt
# Retirement drawdown: the 4% rule with inflation raises and a guardrail `input.json` describes one retiree and one assumed sequence of yearly market returns and inflation rates (synthetic data). Write `solve.py` (Python 3 standard library only) so that `python solve.py input.json answer.json` reads the input and writes the answer. We re-run it on fresh inputs of the same shape, so do not hard-code anything. ## Input `start_age`, `end_age` (integers), `start_balance`, `withdrawal_rate` (e.g. 0.04), `fee_rate` (yearly fraction), `returns` and `inflation` (lists of fractions, one per year, length `end_age - start_age`). ## Rules 1. There are n = `end_age - start_age` years, k = 0 .. n-1. Year k is the year the retiree is age `start_age + k`. 2. The planned withdrawal for year 0 is W0 = `start_balance * withdrawal_rate`. For k >= 1 the planned withdrawal is last year's planned withdrawal times `(1 + inflation[k-1])`. 3. **Guardrail scenario only:** for k >= 1, if `returns[k-1] < 0` (strictly) the raise is skipped that year: the planned withdrawal stays equal to last year's planned withdrawal. Later raises apply to the frozen amount; there is no catch-up. 4. Each year, the withdrawal is taken at the start of the year: actual withdrawal w = min(planned, balance). Then balance = (balance - w) * (1 + returns[k]) * (1 - fee_rate). 5. `depletion_age` = `start_age + k` for the first year k where w < planned (the full planned amount could not be paid), otherwise `null`. `shortfall_total` = sum over all years of (planned - w). `total_withdrawn` = sum of w. 6. `path` = the balance at the end of each year (after rule 4), n values. `final_balance` = the last one. `real_final_balance` = `final_balance` divided by the product of `(1 + inflation[k])` over all n years. 7. Keep full floating-point precision while computing; round money outputs to 2 decimals only when writing. ## Output `answer.json`: `{"standard": S, "guardrail": G}` where each of S and G is an object with keys `final_balance`, `real_final_balance`, `total_withdrawn`, `shortfall_total`, `depletion_age`, `path`. "standard" ignores rule 3; "guardrail" applies it. ## Chart (required visual) Also write `chart.svg` in the working directory: a static, self-contained SVG (root element `<svg>`, no scripts, no external images, fonts, stylesheets or links) that can be rendered headless. It must contain `<polyline id="standard">` and `<polyline id="guardrail">` drawing the two `path` balance series against year. ## Scoring The `chart_svg_static` check (one more check, counted in partial credit) passes only if `chart.svg` exists after the fixture run, parses, has root `<svg>`, contains the ids above with the stated tags, and has no `<script>`, `<img>`/`<image>`, `<link>`, `<iframe>`/`<object>`/`<embed>`, `on*` handlers, or `href`/`src` pointing anywhere except `#...` or `data:`. Its drawing is not graded. Hidden checks (partial credit = fraction passed; all must pass). Money values must match the reference within 0.011; `depletion_age` exactly; `path` must have exactly n values. - `standard_path`, `standard_summary` (the five summary keys), `guardrail_scenario`: on the given `input.json`. - `fresh_standard`, `fresh_guardrail`: on a fresh input. - `depletion_and_shortfall`: both scenarios on a fresh input where the money runs out. Each run has a 60-second limit.
Exact year-by-year balances depend on withdrawal timing, fee application order, the strict-negative guardrail with no catch-up, and how depletion and shortfall are recorded; fresh inputs include one where money runs out. Original benchmark task written for usecaserank.com (not based on a specific public post). Headless, offline run on a reproducible fixture. Each run's notes say how its cost was measured (estimates are marked).
These are synthetic test cases for comparing AI models, not financial advice.
Success criteria: 1. standard_path 2. standard_summary 3. guardrail_scenario 4. fresh_standard 5. fresh_guardrail 6. depletion_and_shortfall 7. chart_svg_static
Best model for this task so far: Claude Haiku 5.5 (effort default (no --effort flag) · thinking on) (success, $0.0062, 23s). Best AI model for Finance / Retirement Planning →
Latest output per model
All runs (8)
88% pass rate across 8 eligible runs: 7 pass, 0 partial, 1 fail. Partial and failed runs are listed below with everything else.ⓘ
| Model | Cost | Time | Step-insⓘ | Autonomy | Outcome | Trustⓘ | Date | Compare |
|---|---|---|---|---|---|---|---|---|
| ZGLM 4.7 (Venice)thinking on | $0.01 | 3m | 0 | Fully autonomous | pass | Trust 80% | 2026-11-04 | |
| QQwen3 Coder 480B Turbo (Venice)thinking on | $0.0091 | 5m | 0 | Fully autonomous | pass | Trust 80% | 2026-10-24 | |
| DDeepSeek V4.1 Flash (Venice)thinking on | $0.0073 | 5m | 0 | Fully autonomous | pass | Trust 80% | 2026-10-24 | |
| MMistral Small 3.2 24B Instruct (Venice)thinking on | $0.0064 | 5m | 0 | Fully autonomous | fail | Trust 80% | 2026-10-24 | |
| OGPT-6.1 Soldefault · thinking off | $0.05 | 2m | 0 | Fully autonomous | pass | Trust 80% | 2026-10-20 | |
| AClaude Haiku 5.5default · thinking on | $0.0062 | 23s | 0 | Fully autonomous | pass | Trust 80% | 2026-10-20 | |
| AClaude Opus 5.5default · thinking on | $0.15 | 28s | 0 | Fully autonomous | pass | Trust 80% | 2026-10-20 | |
| AClaude Sonnet 5.5default · thinking off | $0.06 | 15s | 0 | Fully autonomous | pass | Trust 80% | 2026-10-20 |
Embed this result
A live badge for this use case. It links back here and updates as new runs are published.
Get new runs and ranking changes weekly
Which models got better or cheaper on real tasks like this one.