var pile, lefthand, righthand, fingers, line, i;

pile = 50 - 1;
line = 0;

for(i = 0; i < 3; i++) {
    righthand = Math.floor(Math.random() * (pile - 2)) + 2;
    lefthand = pile - righthand;
    
    fingers = 1; righthand--;
    fingers += (lefthand % 4 == 0 ? 4 : lefthand % 4);
    fingers += (righthand % 4 == 0 ? 4 : righthand % 4);
    pile -= fingers;
    
    line += (fingers == 9 || fingers == 8 ? 2 : 3);
}

if (line == 6) {console.log("Old Yin");}
if (line == 7) {console.log("Young Yang");}
if (line == 8) {console.log("Young Yin");}
if (line == 9) {console.log("Old Yang");}