I started with a game position, but found that there were too many possible variations, so I simplified the problem. Perhaps it's a bit too simplified now.
(;AB[jc]AB[jb]AB[kb]AB[lc]AB[kd]AB[id]AB[ie]AB[if]AW[jd]AW[je]AW[ld]AW[ic]AW[ib]AW[gc]AW[nd]AW[nc]AW[nb]AW[ne]AW[mf]AW[lg]AW[kh]AW[jh]AW[ih]AW[hg]AW[gf]AW[ge]AB[lb]AB[la]AB[ja]AW[fb]AW[na]C[Black to play. Try to get the best result. Assume there are no external ko threats.]AP[goproblems]
(;B[kf];W[ke];B[le];W[kc]
(;B[md]C[RIGHT])
(;B[jf]C[Slightly inferior to N16RIGHT]))
(;B[lf];W[kf]C[You could have kept all the stones.])
(;B[ke];W[jf])
(;B[le];W[kf]C[You could have kept all the stones.])
(;B[jf];W[ke];B[le];W[kf]C[You could have kept all the stones.])
(;B[kg];W[kf]C[You could have kept all the stones.])
(;B[jg];W[kf]))