corrected version can generate for values of L larger than two
and has the option of omitting the slack variables