Skip to content

Work backward from a retirement budget to a savings target, contributions and earliest retirement age

Exact prompt

# Work backward from a retirement budget: savings target, contributions and earliest retirement age `input.json` describes a saver (synthetic numbers). Write `solve.py` (Python 3 standard library only) so that `python solve.py input.json answer.json` computes how much they need, how much they must save each year, and the earliest age they could retire. We re-run it on fresh inputs, so do not hard-code anything. ## Input `current_age`, `retire_age`, `end_age` (integers), `spend_today` (yearly spending in today's dollars), `inflation`, `return_pre` (yearly return before retirement, never 0), `return_post` (after), `current_savings`, `gross_income`, `actual_contribution` (what they save per year now), `part_time_income_today` (yearly part-time income in today's dollars), `part_time_years`. ## Rules 1. For a retirement age A, the first retirement year's spending is S = `spend_today * (1 + inflation) ** (A - current_age)`; spending in retirement year k (k = 0 .. end_age - A - 1) is S * (1 + inflation) ** k. 2. Part-time variant: income in retirement year k is `part_time_income_today * (1 + inflation) ** (A - current_age + k)` for k < `part_time_years`, else 0. The withdrawal is max(0, spending - income). 3. Withdrawals happen at the start of each retirement year. The **target** for age A is the sum over k of withdrawal_k / (1 + return_post) ** k (no part-time income), and **target_with_part_time** uses rule 2. 4. Saving: with m = A - current_age and g = (1 + return_pre) ** m, the projected savings at A with a level contribution C at the end of each year is `current_savings * g + C * (g - 1) / return_pre`. 5. `required_contribution` = the C that makes the projection equal the target for A = `retire_age`, but never below 0; the same with the part-time target gives `required_contribution_with_part_time`. `required_savings_rate` = required_contribution / gross_income (6 decimals). `projected_at_retire_age` = the projection with C = `actual_contribution`. 6. `earliest_retire_age` = the smallest integer A from current_age + 1 to end_age - 1 where the projection with `actual_contribution` >= the target for that A; `null` if none. `earliest_retire_age_with_part_time` does the same against the part-time target. 7. Round money to 2 decimals only when writing. ## Output `answer.json` keys: `target`, `target_with_part_time`, `required_contribution`, `required_contribution_with_part_time`, `required_savings_rate`, `projected_at_retire_age`, `earliest_retire_age`, `earliest_retire_age_with_part_time`. ## Scoring Hidden checks (partial credit = fraction passed; all must pass), money within 0.011, rate within 0.000001, ages exact: `savings_target`, `part_time_target`, `required_contributions`, `earliest_ages` on the given input; `fresh_run_1` and `fresh_run_2_edge_cases` (all keys; the second input has part-time income above spending and a small contribution) on fresh inputs. Each run has a 60-second limit.

Start-of-year withdrawals discounted at the post-retirement return, part-time income inflated from today and floored at zero withdrawals, end-of-year contribution annuity, and a per-age search where the target moves with the age. 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. savings_target 2. part_time_target 3. required_contributions 4. earliest_ages 5. fresh_run_1 6. fresh_run_2_edge_cases

Best model for this task so far: Claude Haiku 5.5 (effort default (no --effort flag) · thinking on) (success, $0.0049, 19s). Best AI model for Finance / Retirement Planning →

Run this on another model

All runs (12)

83% pass rate across 12 eligible runs: 10 pass, 0 partial, 2 fail. Partial and failed runs are listed below with everything else.ⓘ

Runs for this use case
ModelCostTimeStep-insⓘAutonomyOutcomeTrustⓘDateCompare
?MiniMax M2.5 (Venice)thinking on$0.014m0Fully autonomouspassTrust 80%2026-10-27
ZGLM 4.7 (Venice)thinking on$0.008712m0Fully autonomouspassTrust 80%2026-10-26
MMistral Small 3.2 24B Instruct (Venice)thinking on$0.001724s0Fully autonomousfailTrust 80%2026-10-25
KKimi K3.1 Pro (Venice)thinking on$0.0660s0Fully autonomouspassTrust 80%2026-10-25
GGemma 4 31B Instruct (Venice)thinking on$0.00658m0Fully autonomouspassTrust 80%2026-10-24
DDeepSeek V4.1 Flash (Venice)thinking on$0.028m0Fully autonomouspassTrust 80%2026-10-24
KKimi K2.5 (Venice)thinking on$0.0515m0Fully autonomousfailTrust 80%2026-10-24
QQwen3 Coder 480B Turbo (Venice)thinking on$0.009942s0Fully autonomouspassTrust 80%2026-10-22
OGPT-6.1 Soldefault · thinking on$0.0450s0Fully autonomouspassTrust 80%2026-10-20
AClaude Haiku 5.5default · thinking on$0.004919s0Fully autonomouspassTrust 80%2026-10-20
AClaude Opus 5.5default · thinking on$0.1119s0Fully autonomouspassTrust 80%2026-10-20
AClaude Sonnet 5.5default · thinking on$0.0515s0Fully autonomouspassTrust 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.

UseCaseRank badge for Work backward from a retirement budget to a savings target, contributions and earliest retirement age

Get new runs and ranking changes weekly

Which models got better or cheaper on real tasks like this one.