Name: Anonymous 2012-08-26 2:11
I'm looking to program a function that can check if you can "make 10" from some 4 digit number (0000 to 9999).
The function should use these rules when performing the check:
https://www.facebook.com/pages/Train-Carriage-Game/108348062559174?sk=info
Does /prog/ know if there's a simple way to perform such a check short of checking every combination individually? I obviously don't want to be writing the following:
The function should use these rules when performing the check:
https://www.facebook.com/pages/Train-Carriage-Game/108348062559174?sk=info
Does /prog/ know if there's a simple way to perform such a check short of checking every combination individually? I obviously don't want to be writing the following:
boolean makesTen (int a, int b, int c, int d) {
if (a + b + c + d == 10) {
return true;
} else if (-a + b + c + d == 10) {
return true;
} else if (a - b + c + d == 10) {
return true;
}
...
...
} else {
return false;
}
}