Here's another solution. It recursively tries filling in the zeros until a solution is reached. A few ideas are used to speed the process up:

- Stop if it's never going to work.
- If we know the target total for the sublists, fill in any single zeros.
- Target the biggest total sublist for trials.
- Don't trial any numbers that are obviously too big.

Example:

```
pseudoku[puzzle] // Reap // Last // Last
```

```
{{{7, 2}, {1, 8}, {6, 3}, {4, 5}}, {{7, 2}, {1, 8}, {6, 3}, {5, 4}},
{{7, 2}, {4, 5}, {6, 3}, {1, 8}}, {{7, 2}, {4, 5}, {6, 3}, {8, 1}},
{{7, 2}, {5, 4}, {6, 3}, {1, 8}}, {{7, 2}, {5, 4}, {6, 3}, {8, 1}},
{{7, 2}, {8, 1}, {6, 3}, {4, 5}}, {{7, 2}, {8, 1}, {6, 3}, {5, 4}}}
```

This does only 75 calls to the routine.

The code:

```
ClearAll@pseudoku;
pseudoku[p_] :=
Module[{n = Length@p, k = Length@First@p,
available, complete, partial, target, big, bigi, zeroi, c, q, trial
},
available = Complement[Range[n k], Flatten@Union@p];
complete = Select[p, Min@# > 0 &];
If[Length@complete == Length@p && SameQ @@ Total /@ p,
Sow@p,(* Got a solution *)
partial = Select[p, Min@# == 0 &];
If[Length@complete > 0 && ! SameQ @@ Total /@ complete,
(* fail *),
target = n k^2; c = 0;
If[Length@complete > 0,
target = Total@First@complete;
(* Fill in the sublist with only one zero *)
q = p /. a : {_Integer ..} /;
Count[a, 0] == 1 &&
MemberQ[available, target - Total@a] :> (++c; (a /.
0 -> target - Total@a));
(* Could do some smarter possibilities with IntegerPartitions of the remainder *)
];
If[c > 0, pseudoku[q],
(* Try some more possibilities *)
big = Last@SortBy[partial, Total];
bigi = First@First@Position[p, big];
zeroi = First@First@Position[big, 0];
trial = Select[available, # <= target - Total@big &];
If[Length@trial > 0,
pseudoku[ReplacePart[p, {bigi, zeroi} -> #]] & /@ trial];
]
];
];
];
```

2Please clarify: Can you "insert" the same integer value in different "slots", or must all $n l$ be distinct? – David G. Stork – 2018-03-07T00:36:05.727

@DavidG.Stork Of course, I'm sorry I forgot to mention it! All must be distinct. I will add it to the question. Thank you. – Nico A – 2018-03-07T00:43:49.117