Fail triangle solutions that ignore reachability

Merged
C1
4h ago
+82-0

Every built-in Mine Level Descent (triangle) case gave the same answer to a correct bottom-up solution, to the sum of each level's minimum, and to a greedy walk that steps to the cheaper child, so both mistakes the problem's own pitfalls name passed all five cases.

This adds two cases to the triangle judge in problem-bank/judges.json, appended after the existing five so the scenario page's examples keep their indexes, and regenerates web/judges/mine-level-descent.json with python3 scripts/gen-problems.py. Each new case puts the cheapest chambers where a crew cannot reach them from each other, and each fails both wrong approaches:

CaseExpectedBottom-upSum of each level's minimumGreedy smaller child
cheapest values not connected: [[-1],[2,3],[1,-1,-3]]-1-1-20
cheaper step misses the deep saving: [[1],[2,3],[4,5,-10]]-6-6-77

Both labels are added to the tricky-case list in tests/web/contract.rs, so dropping either case fails static_problem_bank_and_judges_cover_each_problem.

Validation, on Ubuntu 24.04 under WSL:

  • ./scripts/test.sh portable passes. Skipped only for missing local tools: commentflow, ruff, shfmt, shellcheck, cargo-audit, actionlint.
  • cargo test --locked --test web static_problem_bank_and_judges_cover_each_problem passes.
  • In a local make web build of this branch, with C++: the bottom-up solution passes 7/7, and the level-minimum and greedy solutions from #432 each pass 5/7, failing only the two new cases with the values in the table.

Closes #432


Summary by cubic

Adds two test cases to the triangle judge that catch solutions which ignore reachability, closing #432. Previously, all five cases produced the same answer for a correct bottom-up solution, the sum of each level's minimum, and a greedy walk to the cheaper child, so the two incorrect approaches went undetected. The new cases place the cheapest chambers where the crew cannot reach them from each other, causing both wrong approaches to fail while correct solutions still pass.