Puzzle 8-10-08 (answer)

Steven Schveighoffer schveiguy at yahoo.com
Mon Aug 11 10:22:07 PDT 2008


import tango.io.Stdout;

void main()
{
    for(int m = 0; m * 3 <= 100; m++)
        for(int c = 0; c + m <= 100; c+=2)
        {
            int w = 100 - m - c;
            int b = m * 3 + c / 2 + w * 2;
            if(b < 100)
                break;
            if(b == 100)
                Stdout.formatln("men = {}, women = {}, children = {}", m, w, 
c);
        }
}


men = 2, women = 30, children = 68
men = 5, women = 25, children = 70
men = 8, women = 20, children = 72
men = 11, women = 15, children = 74
men = 14, women = 10, children = 76
men = 17, women = 5, children = 78
men = 20, women = 0, children = 80

-Steve 




More information about the Digitalmars-d-learn mailing list