#include #include "time.h" //Compute the code for column "a" plus m-multiple of column "b". //Each column is coded by an integer from 0 to 124: //the code for column (a1,a2,a3) is 25 a1 + 5 a2 + a3. unsigned int Add(unsigned int a, unsigned int m, unsigned int b) { unsigned int t1,t2,t3; t1=(a/25 + b/25*m)%5; t2=(a%25/5 + b%25/5*m)%5; t3=(a%5 + b%5*m)%5; return(t1*25+t2*5+t3); } void main() { const N=22; unsigned int i,j,k,l,code,inv,tnum,lostnum; unsigned int col[N], tcol[9]; bool Gen[N][5][125], adm[N+1][125]; FILE *fp; time_t t; t = time(NULL); fp=fopen("out.txt","w"); fclose(fp); fp=fopen("out.txt","a"); fclose(fp); //The first four columns are 000,100,010,001. col[0]=0; col[1]=25; col[2]=5; col[3]=1; //Calculate all j-column sums of the first four columns (0<=j<=4). //The j-column sums of the first column are all {0}. for (j=0;j<5;j++) { Gen[0][j][0]=1; for (k=1;k<125;k++) Gen[0][j][k]=0; } //Compute the j-column sums recursively. for (i=1;i<4;i++) { //The j-column sums of first i columns contains that of first i-1 columns. for (j=0;j<5;j++) { for (k=0;k<125;k++) Gen[i][j][k]=Gen[i-1][j][k]; } //New (j+l)-column sums are obtained from the j-column sums of //the first i-1 column and l multiple of column i. for (j=0;j<5;j++) { for (k=0;k<125;k++) { if (Gen[i-1][j][k]) { for (l=1;l<5-j;l++) Gen[i][j+l][Add(k,l,col[i])]=1; } } } } //Compute the admissible code for the fifth column. //"Admissible" means that after adding new column, //the sums of 5 columns can NOT be zero. //If "c" is a j-column sum of first four columns, //then the fifth colum can NOT be j^(-1) multiple of "c". for (k=0;k<125;k++) adm[4][k]=1; for (j=1;j<5;j++) { if ((j==1) || (j==4)) inv=j; else inv=5-j; for (k=0;k<125;k++) { if (Gen[3][j][k]) adm[4][Add(0,inv,k)]=0; } } //Start from the fifth column to search for a counter-example. //Repeat until we have to change the 4th column or //we can get a counter-example. i=4; code=2; tnum=0; lostnum=0; while ((i>3) && (i