3 ms·
The second answer is a C program. It specifies the constraints and loops over all the possible solutions. That's the most naive constraint solver possible, but
by dmurray 7y ago
The second answer is a C program. It specifies the constraints and loops over all the possible solutions. That's the most naive constraint solver possible, but adequate for this task.
Once you put in the effort of translating the problem into constraints, the Prolog solution is trivial, because the Prolog compiler is a constraint solver.