with-transformed array reduction constraints from scratchReduction methods (sum(), product(), and(), or(), xor()) collapse an array to one value. With with (expr), they reduce the expression’s result for each element instead of the element itself; item names the element inside the expression.
That makes sum() with a counter: arr.sum() with (item == N ? 1 : 0) is the number of elements equal to N.
Fix the class below.
RequirementsEach a constraint using sum() with (…)
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.