/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 0; tab-width: 4 -*-  */
/*
 * shannon.c
 * Copyright (C) 2018 TikalonLLC <gualtieri@ieee.org>
 * 
 * Shannon is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Shannon is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 /*
 References:
 The American Mathematical Monthly, vol. 40, No. 8 (October, 1933), pp. 491-492.
 The American Mathematical Monthly, vol. 41, No. 3 (March, 1934), pp. 191-192.
 */

#include <stdio.h>
#include <time.h>

int J,L,M,N,R,S,T,U,X,Y;
clock_t start;
clock_t stop;

int main()
{

start = clock();

//This is a brute-force attack with ten nested loops!

for (J=0;J<10;J++)
{
for (L=0;L<10;L++)
{
for (M=0;M<10;M++)
{
for (N=0;N<10;N++)
{
for (R=0;R<10;R++)
{
for (S=0;S<10;S++)
{
for (T=0;T<10;T++)
{
for (U=1;U<10;U++)
{
for (X=1;X<10;X++)
{
for (Y=1;Y<10;Y++)
{


if(((100*U*L)+(10*U*M)+(U*N))==((1000*R)+(100*T)+(10*Y)+X))
{
if((((100*S)+(10*T)+(U))-((100*T)+(10*Y)+X) == ((100*T)+(10*Y)+Y)) )
{
if(((100*X*L)+(10*X*M)+(X*N))==((1000*T)+(100*Y)+(10*Y)+J))
{
if((N-J)==Y)
{
printf("J = %d\tL = %d\tM = %d\tN = %d\tR = %d\tS = %d\tT = %d\tU = %d\tX = %d\tY = %d\n",J,L,M,N,R,S,T,U,X,Y);
stop = clock();
printf("Elapsed time (sec) = %f\n",(double)(stop - start)/1E6);
}
}
}
}

}
}
}
}
}
}
}
}
}
}

stop = clock();
printf("Elapsed time to program end (sec) = %f\n",(double)(stop - start)/1E6);

return (0);
}

