Transform is func(context.Context,int) (int,error). Implement Prototype(ctx,inputs,workers,transform) ([]int,error) sequentially, validating workers>0 and nonnil transform first. Solve uses at most workers concurrent transforms and a channel-based job queue. ctx is nonnil; input/sums fit int. Both return results in input order, detached/nonempty rules: empty input yields a nonnil empty result if ctx active. A pre-canceled ctx returns nil and its error without callbacks, including empty input. On transform error, return nil and that classifiable error; final cancels a derived context, stops dispatch, and waits for every started callback. On parent cancellation return nil and context error, also wait. If several callbacks fail, any first observed error is acceptable. Transform callbacks honor ctx and are safe for concurrent use. Do not close/alter caller context, mutate inputs, or return while owned workers remain active. Prototype does not need parallelism; final must allow up to workers callbacks to overlap when jobs permit.

Edit exercise.go; retain the public types and signatures. prototype and final are separate stages. The executable tests recover panics from direct calls and harness-owned goroutines as named failures, including panic(nil). A panic in a goroutine started by your implementation must be recovered in that goroutine; its caller cannot recover it, and an unhandled panic can terminate the process. Cancellation is cooperative; the local CLI timeout remains the hard stop for unfinished waits. Tests 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.