Solution (source code)

= Solution

An <affine gap penalty> charges a larger opening cost than extension cost, reflecting that a single insertion or deletion event can span several residues. For a gap of length $\ell\geq1$, explicitly choose
$$
g(\ell)=o+e(\ell-1),\qquad o=4,\quad e=1.
$$
The supplied <sequence alignment> has two gap runs, of lengths one and two. Its residue–residue score remains $24$, so this choice gives
$$
\boxed{S=24-g(1)-g(2)=24-4-5=15}.
$$
More generally, this <affine gap penalty> convention gives $S=24-2o-e$. There is no unique numerical rescore until opening and extension costs are chosen. A concave length-dependent <gap penalty> can make very long gaps progressively cheaper per added residue; distinct terminal <gap penalties> can accommodate incomplete sequence ends. Each choice encodes a different assumption about insertions, deletions or sequence completeness.