Prototype: Prototype(ctx context.Context,in <-chan int,out chan<- int) error synchronously forwards values in order until input closes or ctx cancels. It never closes caller-owned in/out. Normal input closure returns nil; cancellation returns ctx.Err().

Final: Solve(ctx context.Context,in <-chan int) (<-chan int,<-chan error) starts one owned bridge, returns an unbuffered value channel and a buffered terminal-status channel. Forward in order. Close value output when done, then emit exactly one terminal error (nil normal, ctx.Err canceled) and close status. Every receive/send must have a cancellation path; a nil input is allowed and waits until canceled. Pre-canceled ctx forwards nothing, even if input is closed. Do not close caller input or cancel parent. On concurrent cancellation, an already-ready send may win; no exact partial prefix is promised. Cancellation must release a bridge blocked on output even if the consumer reads no values. The terminal result means the bridge has finished work.

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.