Reduction and locator methods with with (...) are the usual tool for aggregate constraints (“exactly N elements are X”, “the total stays under a cap”). On the current toolchain they don’t work here, confirmed directly:
find() with in a constraint compiles but is dropped (CONSTRAINTIGN): randomize() succeeds and enforces nothing. True for any array.sum() with on any struct-typed array, even a one-field struct with no cast, produces a query the solver rejects (“Sorts … are incompatible”), and randomize() returns 0. The same reduction on a plain array works.item.cmd_type == WRITE) inside any with (…) crashes the compiler, struct or not.What works is a prefix sum: a separate rand int array, one element per cmd_list entry, each tied to the one before it in a foreach (running[i] == running[i-1] + (...)). Its last element is the total to bound.
Fix the class below.
Requirements
One working answer: brokenbench's own fix for this exercise. Try a few runs first.
What changes, against the code you started with:
docker run --pull always --rm -p 127.0.0.1:8787:8787 ghcr.io/adibis/brokenbench-runnerLooking for a runner on this computer…
The first start downloads about 250 MB; after that it starts in seconds and only downloads again when there's an update. Your code goes to the runner on your computer, not to chipdv.io.