Advertisement
Spocoman

05. Tseam Account

Jan 23rd, 2022
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.  
  3.     let print = input[0].split(" ");
  4.  
  5.     for(let i = 1; input[i] !== "Play!"; i ++) {
  6.         let command = input[i].split(" ");
  7.         if (!print.includes(command[1]) && command[0] === "Install") {
  8.             print.push(command[1]);
  9.         }
  10.         if (print.includes(command[1]) && command[0] === "Uninstall") {
  11.             print.splice(print.indexOf(command[1]), 1);
  12.         }
  13.         if (print.includes(command[1]) && command[0] === "Update") {
  14.             print.push(print.splice(print.indexOf(command[1]), 1));
  15.         }
  16.         if(command[0] === "Expansion") {
  17.             let exp = command[1].split("-");
  18.             if(print.includes(exp[0])) {
  19.                 print.splice(print.indexOf(exp[0]) + 1, 0, exp.join(":"));
  20.             }
  21.         }
  22.     }
  23.     console.log(print.join(" "));
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement