April 28 2007 6:41:24.149 AM ZERO_ONE FORTRAN90 version Tests of functions designed to return 1 if I == J. The challenge is to design a one line arithmetic function which accepts two integer arguments I and J, and returns 1 if they are equal and 0 otherwise. While solutions are possible involving logical operations, conversions, and other sophisticated means, a solution is preferred that is as simple and close to "number-theoretical" as possible. TEST00 For comparison only. if ( i == j ) then a(i,j) = 1 else a(i,j) = 0 end if 100000000000000000000 010000000000000000000 001000000000000000000 000100000000000000000 000010000000000000000 000001000000000000000 000000100000000000000 000000010000000000000 000000001000000000000 000000000100000000000 000000000010000000000 000000000001000000000 000000000000100000000 000000000000010000000 000000000000001000000 000000000000000100000 000000000000000010000 000000000000000001000 000000000000000000100 000000000000000000010 000000000000000000001 TEST01 a(i,j) = 1 - int ( abs ( sign ( 1, i - j ) - sign ( 1, j - i ) ) ) / 2 100000000000000000000 010000000000000000000 001000000000000000000 000100000000000000000 000010000000000000000 000001000000000000000 000000100000000000000 000000010000000000000 000000001000000000000 000000000100000000000 000000000010000000000 000000000001000000000 000000000000100000000 000000000000010000000 000000000000001000000 000000000000000100000 000000000000000010000 000000000000000001000 000000000000000000100 000000000000000000010 000000000000000000001 TEST03 a(i,j) = (i/j) * (j/i) Test restricted to I, J greater than 0. Thanks to David Levine, St Bonaventure University. 1000000000 0100000000 0010000000 0001000000 0000100000 0000010000 0000001000 0000000100 0000000010 0000000001 TEST04 a(i,j) = 1 / ( 1 + ( i - j ) * ( i - j ) ) Thanks to David Faden, Iowa State University. 100000000000000000000 010000000000000000000 001000000000000000000 000100000000000000000 000010000000000000000 000001000000000000000 000000100000000000000 000000010000000000000 000000001000000000000 000000000100000000000 000000000010000000000 000000000001000000000 000000000000100000000 000000000000010000000 000000000000001000000 000000000000000100000 000000000000000010000 000000000000000001000 000000000000000000100 000000000000000000010 000000000000000000001 TEST05 a(i,j) = 1 - min ( abs ( i - j ), 1 ) Thanks to David Faden, Iowa State University. 100000000000000000000 010000000000000000000 001000000000000000000 000100000000000000000 000010000000000000000 000001000000000000000 000000100000000000000 000000010000000000000 000000001000000000000 000000000100000000000 000000000010000000000 000000000001000000000 000000000000100000000 000000000000010000000 000000000000001000000 000000000000000100000 000000000000000010000 000000000000000001000 000000000000000000100 000000000000000000010 000000000000000000001 TEST06 a(i,j) = 1 - ( abs ( i - j ) + 1 - abs ( abs ( i - j ) - 1 ) ) / 2 Thanks to David Faden, Iowa State University. 100000000000000000000 010000000000000000000 001000000000000000000 000100000000000000000 000010000000000000000 000001000000000000000 000000100000000000000 000000010000000000000 000000001000000000000 000000000100000000000 000000000010000000000 000000000001000000000 000000000000100000000 000000000000010000000 000000000000001000000 000000000000000100000 000000000000000010000 000000000000000001000 000000000000000000100 000000000000000000010 000000000000000000001 TEST07 a(i,j) = 1 - ( i - j ) / ( i - j + 0.1 ) Thanks to Li Wang, Washington State University 100000000000000000000 010000000000000000000 001000000000000000000 000100000000000000000 000010000000000000000 000001000000000000000 000000100000000000000 000000010000000000000 000000001000000000000 000000000100000000000 000000000010000000000 000000000001000000000 000000000000100000000 000000000000010000000 000000000000001000000 000000000000000100000 000000000000000010000 000000000000000001000 000000000000000000100 000000000000000000010 000000000000000000001 ZERO_ONE Normal end of execution. April 28 2007 6:41:24.152 AM