in reply to Re^2: Seven by seven farming puzzle
in thread Seven by seven farming puzzle
Sadly you have to find the number of solutions, not just find one solution.
Given the contents of the first two rows, compute the number of ways the rest of the table can be filled.
For example, for the input you consider above, [[2, 1, 0, 0, 2, 2, 1], [0, 2, 2, 1, 1, 0, 2]], the output should be 4909920 because that's the number of solutions.
Finding just one solution (for each of the ten inputs) would be much easier done by hand than by a program.
In addittion, this part looks very inefficient to me:
wouldn't this backtrack multiple times for any two lists that differ in more than one place? Wouldn't it cause to return a single solution multiple times?different_lists([A|TA], [B|TB]) :- ( A #\= B ; different_lists(TA, TB)).
It seems like a bad idea to me to mix constraint programming with this kind of early backtracking. If I had to write this program, I'd either not use any constraint programming and backtrack over everything, or post everything as constraints and backtrack only once at the end with label.
|
|---|