I have the following riddle:
How do I solve this in Java, using while loops? I had an idea on how to do it with for-loops, but it doesn't work using for-loops
So far, all I have is the following, which seems to be going through all possible combinations, but is incredibly slow, so I suspect I made some mistake there...
Can someone please tell me how to solve this, I am getting crazy trying to...

How do I solve this in Java, using while loops? I had an idea on how to do it with for-loops, but it doesn't work using for-loops
So far, all I have is the following, which seems to be going through all possible combinations, but is incredibly slow, so I suspect I made some mistake there...
Java:
public static void main(String[] args) {
int star = 0, delta = 0, diamond = 0, heart = 0, nabla = 0, square = 0, circleDot = 0, cross = 0, circleX = 0,
circle = 0;
int equation1 = getValue(star, delta, diamond) + getValue(heart, delta, nabla);
int result1 = getValue(nabla, square, square);
int equation2 = getValue(heart, nabla, circleDot) + getValue(square, square, star);
int result2 = getValue(cross, square, circleX);
int equation3 = getValue(nabla, square, square) - getValue(cross, square, circleX);
int result3 = getValue(heart, nabla, circle);
// Brute force solution with while loop
while (star < 10) {
while (delta < 10) {
while (diamond < 10) {
while (heart < 10) {
while (nabla < 10) {
while (square < 10) {
while (circleDot < 10) {
while (cross < 10) {
while (circleX < 10) {
while (circle < 10) {
if (equation1 == result1 && equation2 == result2
&& equation3 == result3) {
System.out.println("Star: " + star + ", Delta: " + delta
+ ", Diamond: " + diamond + ", Heart: " + heart
+ ", Nabla: " + nabla + ", Square: " + square
+ ", CircleDot: " + circleDot + ", Cross: " + cross
+ ", CircleX: " + circleX + ", Circle: " + circle);
}
circle++;
}
circle = 0;
circleX++;
}
circleX = 0;
cross++;
}
cross = 0;
circleDot++;
}
circleDot = 0;
square++;
}
square = 0;
nabla++;
}
nabla = 0;
heart++;
}
heart = 0;
diamond++;
}
diamond = 0;
delta++;
}
delta = 0;
star++;
}
}
public static int getValue(int a, int b, int c) {
int result = a * 100 + b * 10 + c;
return result;
}
Can someone please tell me how to solve this, I am getting crazy trying to...