The formulas
The largest feasible W is found by testing each value of W from 0 upwards, not by a shortcut assumption.
With no wrong answers, the minimum correct answers needed is ceil(T ÷ P), where T is the target and P is the marks per correct answer.
For any chosen number of wrong answers W, the minimum correct needed becomes ceil((T + (N × W)) ÷ P), where N is the penalty per wrong answer. A combination only counts if minimumCorrect + W fits inside the total question count Q.
