$countones() would make this trivial; the point is the array-reduction technique. sum() with needs an array, and current_data ^ previous_data is a single packed value. Two things that look like they should work and don’t compile: chaining the streaming operator {<<{...}} into a method call, and comparing an unpacked array to a streaming expression with ==.
What works: an array of rand bit, each element tied to one bit of the XOR by a foreach constraint, then reduced. Cast each element with int'(item), or the count wraps at 1 bit.
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.