Fail stock III solutions that keep only two runs
Problem and behavior
Every Spot Capacity Round Trips case gave the same answer to a correct solution and to one that splits the prices into rising runs and adds the two largest run gains (the C++ solution in #691). That solution never joins two runs into one trade across a dip, yet it passed all six cases. After this change it fails the new case best trades span a dip, [1,2,4,2,5,7,2,4,9,0]: the right answer is 13 (buy at 1 and sell at 7, then buy at 2 and sell at 9), and the two largest runs give 12.
Approach
One case appended to the end of the judge in problem-bank/judges.json, so the indexes of the existing cases do not move, and web/judges/spot-capacity-round-trips.json regenerated from it. The label joins the tricky-case list in tests/web/contract.rs, as the triangle cases did in d429ee70, so the case cannot be dropped silently. tests/golden/task-posed.json takes the problem's new judge hash; both the Rust and the Python golden checks compute the same value.
Validation
- A correct state machine solution passes 7/7 in Python and in C++ (compiled locally with clang), and so does a split-point solution in Python.
- The two-runs solution fails only the new case, with
got 12, in both languages. - In the app, the C++ two-runs solution now shows 6/7 with the new case failing:
./scripts/test.shpasses every gate exceptreview-memory-tests, which fails the same way onmainhere because mygh2.46 lacks the attestation flags, andshell-syntax, where the local shellcheck 0.11.0 warns aboutscripts/git-post-commit.sh, which this change does not touch. Not checked locally: cargo-audit, cargo-deny, actionlint and the desktop lane, none of which covers a file this change touches.
Closes #691
Summary by cubic
Adds a best-time-to-buy-and-sell-stock-iii case where the best two trades span a dip, so a flawed solution that splits prices into rising runs and keeps the two largest run gains now fails. Previously all six cases gave the same answer to correct and flawed solutions.
- The new case
[1,2,4,2,5,7,2,4,9,0]expects 13; the two largest runs give 12. - Appends the case to
problem-bank/judges.jsonand regeneratedweb/judges/spot-capacity-round-trips.jsonfrom it. - Updates the golden hash in
tests/golden/task-posed.jsonand adds the case label to the tricky-case list intests/web/contract.rsso it cannot be dropped silently.