package mathgrid;
/**
*
@author Ian Baer
*
*/
public class MathGridSolver
{
public static void main(String[] args)
{
int a1 = 0;
int a2 = 0;
int a3 = 0;
int a4 = 0;
int a5 = 0;
int a6 = 0;
int a7 = 0;
int a8 = 0;
int a9 = 0;
int n1c = 0;
int n2c = 0;
int n3c = 0;
int n4c = 0;
int n5c = 0;
int n6c = 0;
int n7c = 0;
int n8c = 0;
int n9c = 0;
for(int x1 = 1; x1 <= 9; x1 ++)
{
for(int x2 = 1; x2 <= 9; x2 ++)
{
for(int x3 = 1; x3 <= 9; x3 ++)
{
for(int x4 = 1; x4 <= 9; x4 ++)
{
for(int x5 = 1; x5 <= 9; x5 ++)
{
for(int x6 = 1; x6 <= 9; x6 ++)
{
for(int x7 = 1; x7 <= 9; x7 ++)
{
for(int x8 = 1; x8 <= 9; x8 ++)
{
for(int x9 = 1; x9 <= 9; x9 ++)
{
n1c = 0;
n2c = 0;
n3c = 0;
n4c = 0;
n5c = 0;
n6c = 0;
n7c = 0;
n8c = 0;
n9c = 0;
if(((x1 + x2) / x3 == 2) && ((x4*x5) / (x6) == 3 ) && ((x7*x8) - x9) == 1)
{
if(((x1 - x4) * x7 == 5) && ((x2 + x5) / x8 == 1) && ((x3 -x6) * x9 == 8))
{
int potentialAnswers[] = {x1, x2, x3, x4, x5, x6, x7, x8, x9};
for(int i = 0; i <= 8; i++)
{
if (potentialAnswers[i] == 1)
{
n1c++;
}
if (potentialAnswers[i] == 2)
{
n2c++;
}
if (potentialAnswers[i] == 3)
{
n3c++;
}
if (potentialAnswers[i] == 4)
{
n4c++;
}
if (potentialAnswers[i] == 5)
{
n5c++;
}
if (potentialAnswers[i] == 6)
{
n6c++;
}
if (potentialAnswers[i] == 7)
{
n7c++;
}
if (potentialAnswers[i] == 8)
{
n8c++;
}
if (potentialAnswers[i] == 9)
{
n9c++;
}
if((n1c == 1) && (n2c == 1) && (n3c == 1) && (n4c == 1) && (n5c == 1) && (n6c == 1) && (n7c == 1) && (n8c == 1) && (n9c == 1))
{
a1 = x1;
a2 = x2;
a3 = x3;
a4 = x4;
a5 = x5;
a6 = x6;
a7 = x7;
a8 = x8;
a9 = x9;
}
}
}
}
}
}
}
}
}
}
}
}
}
int[] answers = {a1, a2, a3, a4, a5, a6, a7, a8, a9};
for(int i = 0; i <=8; i++)
{
System.out.println(answers[i]);
}
}
}