Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Train Carriage Game Solutions

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:


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;
    }
}

Name: Anonymous 2012-08-27 17:18

>>22
I didn't realize this was an exercise in writing bloated code. Just so you know, no rational number to any rational power is going to give you 10, so leaving that out isn't a problem. It is possible to get 10 by multiplying two sums, though, and it's likely that you left that out too.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List