Skip to content

Fail triangle solutions that ignore reachability - #446

Merged
jserv merged 1 commit into
sysprog21:mainfrom
c14094071:triangle-unconnected-case
Oct 23, 2026
Merged

jserv merged 1 commit into
sysprog21:mainfrom
c14094071:triangle-unconnected-case

Conversation

@c14094071

@c14094071 c14094071 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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:

Case Expected Bottom-up Sum of each level's minimum Greedy smaller child
cheapest values not connected: [[-1],[2,3],[1,-1,-3]] -1 -1 -2 0
cheaper step misses the deep saving: [[1],[2,3],[4,5,-10]] -6 -6 -7 7

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 Mine Level Descent tests accept solutions that ignore which chambers are reachable #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.

Written for commit d429ee7. Summary will update on new commits.

View guided diff

Every Mine Level Descent 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. The two new cases
put the cheapest chambers where the crew cannot reach them from each
other, and each fails both wrong approaches while a correct solution
still passes. Their labels join the tricky-case list so they stay.
cubic-dev-ai[bot]

This comment was marked as resolved.

@jserv
jserv requested review from ColtenOuO and alanhc October 23, 2026 07:16
@jserv
jserv merged commit a504944 into sysprog21:main Oct 23, 2026
10 checks passed
@jserv

jserv commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Thank @c14094071 for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mine Level Descent tests accept solutions that ignore which chambers are reachable

2 participants