Problem: find a 5X5 matrix of distinct integers to the fourth power with identical row and column sums.
I have the following code:
ClearAll[findMat2]
findMat2 =
Module[{csums = ConstantArray[#, 5],
mats = Select[DuplicateFreeQ[Join @@ #] &]@
Subsets[Select[DuplicateFreeQ]@
IntegerPartitions[#, {5},
Range[Ceiling[#^(1/4)]]^(4)], {5}]},
Join @@ ((Select[Total[#] == csums &]@
Tuples[{{#[[1]]}, Permutations[#[[2]]],
Permutations[#[[3]]],
Permutations[#[[4]]],
Permutations[#[[5]]]}]) & /@ mats)] &;
solsB = ParallelTable[
findMat2[n] /. {} -> Nothing, {n, 0, 100000000}];
{Total[#[[1, 1]]]} & /@ solsB
And this code solves (I think) the problem I described at the beginning of my question. But it does so very very slowly, is there a way to compute this in a different way and speed up the calculation?