Not a good way to do, but a
computer search#include <stdio.h>
#include <math.h>
const int list4[5] = {1234,1235,1245,1345,2345};
const int list3[10]= {123,124,125,134,135,145,234,235,245,345};
const int powers[25] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216};
void testmatrix();
int main(int argc, const char * argv[]) {
FILE *fp;
fp=freopen("output.txt", "w",stdout);
int i[5];
int j=0,k;
int matrices[60000];
for(i[0]=0;i[0]<25;i[0]++){
for(i[1]=i[0]+1;i[1]<25;i[1]++){
for(i[2]=i[1]+1;i[2]<25;i[2]++){
for(i[3]=i[2]+1;i[3]<25;i[3]++){
for(i[4]=i[3]+1;i[4]<25;i[4]++){
k = powers[i[0]]+powers[i[1]]+powers[i[2]]+powers[i[3]]+powers[i[4]];
matrices[j] = 33554431 - k;
j++;
}
}
}
}
}
//printf("%d",j);
for(k=0;k<j;k++){
//printf("%d %d\n",k,matrices[k]);
testmatrix(matrices[k]);
}
fclose(fp);
return 0;
}
void testmatrix(int mnum){
int i,j,k,l,t3,t4,ch,ch2=0;
int li[4],lj[3];
int matrix[5][5];
if (mnum < 33554432) {
for(i=0;i<5;i++){
for(j=0;j<5;j++){
matrix[j] = mnum % 2;
mnum /= 2;
//printf("%d ",mnum);
}
}
/*printf("\n\n");
for(j=0;j<5;j++){
for(i=0;i<5;i++){
printf("%d ",matrix[j]);
}
printf("\n");
}*/
for(i=0;i<5;i++){
for(j=0;j<10;j++){
t3=list3[j];
t4=list4;
for(k=0;k<3;k++){
lj[2-k] = (t3 % 10) - 1;
t3 /= 10;
}
for(l=0;l<4;l++){
li[3-l] = (t4 % 10) - 1;
t4 /= 10;
}
//printf("LI %d %d %d %d\n",li[0],li[1],li[2],li[3]);
//printf("LJ %d %d %d \n",lj[0],lj[1],lj[2]);
ch = matrix[lj[0]][li[1]] + matrix[lj[0]][li[2]] + matrix[lj[1]][li[0]] + matrix[lj[1]][li[3]] + matrix[lj[2]][li[1]];
//printf("CH %d\n\n",ch);
if(ch == 5) ch2 = 1;
}
}
if(ch2 == 0){
for(j=0;j<5;j++){
for(i=0;i<5;i++){
printf("%d ",matrix[j]);
}
printf("\n");
}
}
}
}
gives us
.
Therefore we have
(Feel free to correct me if my code is wrong; I'm not very good at C)