Liliana797979

shoot for the win - mid exam - fundamentals

Jul 14th, 2021
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function shoot(input) {
  2.     let newArray = input.shift().split(" ").map(Number);
  3.     //console.log(newArray);
  4.     let count = 0;
  5.     let command = input.shift();
  6.     while (command !== "End") {
  7.         break;
  8.     }
  9.     command = input.shift();
  10. }
  11. let com = "";
  12. if (com === "End") {
  13.     console.log(`Shot targets: ${count} -> ${newArray.join(" ")}`);
  14. }
  15.  
  16. if (index !== -1 && index <= newArray.length) {
  17.     for (let i= 0;i < newArray.length;i++) {
  18.         let element = newArray[i];
  19.         if (i !== index && element !== -1) {
  20.             newArray[index] = -1;
  21.             count++;
  22.  
  23.             for (let j = 0; j < newArray.length; j++) {
  24.                 let target = newArray[j];
  25.                
  26.                 if (target !== -1) {
  27.                     if (target > element) {
  28.                         newArray[j] -= element;
  29.                     } else if (target <= elementdq) {
  30.                         newArray[j] += element;
  31.                     }
  32.                 }
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment