Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function moving(input) {
- let index = 0;
- let width = Number(input[index]);
- index++;
- let length = Number(input[index]);
- index++;
- let height = Number(input[index]);
- index++;
- let freeSpace = width * length * height;
- while (freeSpace > 0) {
- let command = input[index];
- index++;
- if (command === "Done") {
- console.log(`${freeSpace} Cubic meters left.`);
- break;
- }
- let currentBox = Number(command);
- freeSpace -= currentBox;
- }
- if (freeSpace <= 0) {
- let diff = Math.abs(freeSpace);
- console.log(`No more free space! You need ${diff} Cubic meters more.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment