Code4Life - Feedback & Strategy

I don’t remember the rules of the lower league, but I think you’re supposed to output 1 line per turn there too (please check the Output section of the statement). If you output more than 1 line per turn, the extra lines are treated as output for the following turns, i.e. you are treated as if you have output something even before you read the inputs for the next turns. Hence the warning you see in the console.

Fix: Make sure you don’t output more than you are asked to.

yea, some changes in the foreach and now is working thx

Below is my code for league Wood 2. It stop always at turn 10 with

Invalid CONNECT: you do not have enough molecules/expertise to launch research on sample 49

/**
 * Bring data on patient samples from the diagnosis machine to the laboratory with enough molecules to produce medicine!
 **/

var projectCount = parseInt(readline());

for (let i = 0; i < projectCount; i++) {
    var inputs = readline().split(' ');
    var a = parseInt(inputs[0]);
    var b = parseInt(inputs[1]);
    var c = parseInt(inputs[2]);
    var d = parseInt(inputs[3]);
    var e = parseInt(inputs[4]);
}

let does = false;
let iters = 0;

// game loop
while (true) {

    //What bot most do
    let action = "";

    for (let i = 0; i < 1; i++) {
        var inputs = readline().split(' ');
        //Const-> var // change later
        var target = inputs[0];
        var eta = parseInt(inputs[1]);
        var score = parseInt(inputs[2]);
        var storageA = parseInt(inputs[3]);
        var storageB = parseInt(inputs[4]);
        var storageC = parseInt(inputs[5]);
        var storageD = parseInt(inputs[6]);
        var storageE = parseInt(inputs[7]);
        var expertiseA = parseInt(inputs[8]);
        var expertiseB = parseInt(inputs[9]);
        var expertiseC = parseInt(inputs[10]);
        var expertiseD = parseInt(inputs[11]);
        var expertiseE = parseInt(inputs[12]);
    }
    readline();
    var inputs = readline().split(' ');
    var availableA = parseInt(inputs[0]);
    var availableB = parseInt(inputs[1]);
    var availableC = parseInt(inputs[2]);
    var availableD = parseInt(inputs[3]);
    var availableE = parseInt(inputs[4]);
    var sampleCount = parseInt(readline());

    for (let i = 0; i < sampleCount; i++) {
        var inputs = readline().split(' ');
        var sampleId = parseInt(inputs[0]);
        var carriedBy = parseInt(inputs[1]);
        var rank = parseInt(inputs[2]);
        var expertiseGain = inputs[3];
        var health = parseInt(inputs[4]);
        var costA = parseInt(inputs[5]);
        var costB = parseInt(inputs[6]);
        var costC = parseInt(inputs[7]);
        var costD = parseInt(inputs[8]);
        var costE = parseInt(inputs[9]);
    }
    let store = (storageA+storageB+storageC+storageD+storageE)>0;

    //Needed molecules array
    let actionA = [];
    if(costA){for(i=0;i<=costA;i++){actionA.push("A")}}
    if(costB){for(i=0;i<=costB;i++){actionA.push("B")}}
    if(costC){for(i=0;i<=costC;i++){actionA.push("C")}}
    if(costD){for(i=0;i<=costD;i++){actionA.push("D")}}
    if(costE){for(i=0;i<=costE;i++){actionA.push("E")}}
    switch(target){
        case "DIAGNOSIS":
            if(does){
                action = "GOTO MOLECULES";
                does = false;
                iters = 0;
            }else{
                action = "CONNECT "+ sampleId;
                does = true;
                iters++;
            }
            break;
        case "MOLECULES":
            if(does && iters==actionA.length){
                action = "GOTO LABORATORY";
                does = false;
                iters = 0;
                actionA = [];
            }else{
                action = "CONNECT ";
                action+=actionA[iters]
                does = true;
                iters++;
            }
            break;
        case "LABORATORY":
            if(does){
                action = "GOTO DIAGNOSIS";
                does = false;
            }else{
                action = "CONNECT "+ parseInt(sampleId+1);
                does = true;
            }
            break;
        default:
            action = "GOTO DIAGNOSIS"
    }

    // Write an action using console.log()
    // To debug: console.error('Debug messages...');

    console.log(action);
}

What can i do?

Collect enough molecules before CONNECT?