Back to the explanation of the Challenger problem

A procedure that makes a random challenger puzzle

> make4challenger:=proc()
local plist,die9,rmat,i,j,printstr;
plist:=[[1,4,2,3],[1,3,4,2],[4,2,1,3],[3,2,4,1],
[2,4,3,1],[4,1,3,2],[3,1,2,4],[2,3,1,4]][rand() mod 8 + 1];
die9:=rand(1..9);
rmat:=[seq([seq(die9(),i=1..4)],j=1..4)];
for i from 1 to 4 do
printstr:=" ";
for j from 1 to 4 do
if j=plist[i] then
printstr:=cat(printstr," %d");
else
printstr:=cat(printstr," ");
fi;
od;
printf(cat(printstr," %d\n"),rmat[i][plist[i]],convert(rmat[i],`+`));
od;
printf(" %2d %2d %2d %2d %2d %2d\n\n",add(rmat[i,5-i],i=1..4),
seq(add(rmat[i,j],i=1..4),j=1..4),add(rmat[i,i],i=1..4));
[[seq([i,plist[i]]=rmat[i,plist[i]],i=1..4)],
map(x->convert(x,`+`),rmat),
map(x->convert(x,`+`),[seq([seq(rmat[j,i],j=1..4)],i=1..4)]),
[add(rmat[i,5-i],i=1..4),add(rmat[i,i],i=1..4)]];
end:
 
 
 
 

> make4challenger();

              4 14
        6       29
     2          25
           5    23
 25 23 17 21 30 24
[Maple Math]

>

>

Back to the explanation of the Challenger problem