10.Spice Must Flow - JS
Някой може ли да ми помогне с това каква проверка ми липсва още тук
-> https://pastebin.com/KHhMkTtt
Изкарвам изчисленията, но имa нещо което явно не проверявам..
Тенкс!
Някой може ли да ми помогне с това каква проверка ми липсва още тук
-> https://pastebin.com/KHhMkTtt
Изкарвам изчисленията, но имa нещо което явно не проверявам..
Тенкс!
The trick with SpiceMustFlow was that if the workers consume another 26 spice after the mine has been abandoned, that the harvested amount can not drop below 0. With the new validation for the harvested amount at lines 21-23, the code should give 100%.
Code:
function spiceMustFlow(startingYield) {
let totalExtract = 0;
let days = 0;
while (startingYield >= 100) {
totalExtract += (startingYield - 26);
// if (startingYield >= 26) {
// }
startingYield -= 10;
days++;
}
// if (startingYield < 100) {
// totalExtract -= 26;
// }
totalExtract -= 26;
if (totalExtract < 0) {
totalExtract = 0;
}
console.log(days);
console.log(totalExtract);
}