Solution (source code)

= Solution

Reversing a word for $w$ gives a word of the same length for $w^{-1}$ because every generator is an <involution>. Applying the same argument to $w^{-1}$ proves
$$
\ell_S(w^{-1})=\ell_S(w).
$$
A shortest word for $w$ followed by $s_i$ gives $\ell_S(ws_i)\leq\ell_S(w)+1$. Conversely, $w=(ws_i)s_i$ gives $\ell_S(w)\leq\ell_S(ws_i)+1$. Hence
$$
\ell_S(ws_i)\in\{\ell_S(w)-1,\ell_S(w),\ell_S(w)+1\}.
$$