I get two solutions from my methods, and presumably the first one is invalid (it starts with a 0). I first used an extremely inefficient brute force method, the bulk of which looks like this:
Code:
    for(T = 0; T <= 9; T ++) {
        for(O = 0; O <= 9; O ++) {
            for(G = 0; G <= 9; G ++) {
                for(D = 0; D <= 9; D ++) {
                    /* ... */
                }
            }
        }
    }
It's really, really inefficient and you probably shouldn't use it. I know it only loops 10**4 = 10,000 times, but still. It's ugly.

Then I wrote a nice recursive solution which worked like this: a list of numbers, from 0 to 9, was created by the caller. Each recursive call would loop through the "remaining" numbers, swap the current number with the last one, and then recurse, telling its recursive instance that there was one less number. This process continued until there were four "saved" numbers, at which point the numbers were examined to see if they met the TOO*4 = GOOD criteria. Example:
Code:
Square brackets indicate "unused" and "saved" sections of the array, respectively.
[0 1 2 3 4 5 6 7 8 9][]
Say the loop picks 7. 7 and 9 will be swapped, and the unused size decremented.
[0 1 2 3 4 5 6 9 8][7]
The process continues . . . pick 5.
[0 1 2 3 4 8 6 9][5 7]
Pick 4.
[0 1 2 3 9 8 6][4 5 7]
Pick 1.
[0 6 2 3 9 8][1 4 5 7]
Now 1 4 5 7 are T O G and D, and we can see if they work out.
So I created a really stupid brute force solution and a far-too-complicated recursive solution. Maybe you can come up with something in between . . . .