66/100 02 The Lift JS Fundamentals.
Здравейте!
Интересно ми е къде греша.Кода се изпълнява с всеки Input който от заданието,но в "Judge" ми дава 66точки.
https://judge.softuni.org/Contests/Practice/Index/2517#1
function solve(input) {
let peopleInQueue = +input.shift();
let wagons = input.toString().split(" ").map((x)=> Number(x));
for(let i = 0; i < wagons.length;i++){
currentWagon = wagons[i];
if(peopleInQueue > 4){
let wagonValue = currentWagon;
currentWagon = 4;
peopleInQueue-= (4 - wagonValue);
wagons[i] = currentWagon;
}else{
currentWagon = peopleInQueue;
peopleInQueue = 0;
wagons[i] = currentWagon;
}
}
let isFull = true;
for(let i = 0; i < wagons.length;i++){
let currenEl = wagons[i];
if(currenEl == 4){
isFull = true;
}else{
isFull = false;
}
}
if(isFull){
console.log(`There isn't enough space! ${peopleInQueue} people in a queue!`);
console.log(wagons.join(" "));
}
if(isFull && peopleInQueue == 0){
console.log(wagons.join(" "));
}
if(!isFull){
console.log("The lift has empty spots!");
console.log(wagons.join(" "));
}
}