Prototype: Prototype(start int) func(int) int returns a stateful callback. Each call adds its delta (signed, including zero) to the current value and returns the new value. Separate calls to Prototype are independent.

Final: NewAccumulator(start int) (add func(int) int,read func() int) returns two closures sharing one captured total; read never changes it. MakeAccumulators(starts []int) []func(int) int returns one independent add closure per initial value in order, copies initial values, nonnil empty for empty input. Function aliases intentionally share the same captured accumulator. Inputs/sums fit int, calls single-threaded. Preserve starts, including later caller mutation. No package-global mutable state.

Edit exercise.go; retain the public types and signatures. prototype and final are separate stages. The executable tests recover panics as failures, report named checks, and exit nonzero on any failure. A successful run must execute at least one check. Tests use logical time or explicit synchronization where relevant.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.