Solution (source code)

= Solution

A <context-free grammar> is in <Chomsky normal form> when every production is of one of the forms
$$
A\to BC,
\qquad
A\to a,
$$
where $A,B,C$ are nonterminal symbols and $a$ is a terminal symbol. The conventional exceptional production $S\to\epsilon$ may be allowed when the language contains the empty word, with $S$ excluded from right-hand sides.