Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let print = input[0].split(" ");
- for(let i = 1; input[i] !== "Play!"; i ++) {
- let command = input[i].split(" ");
- if (!print.includes(command[1]) && command[0] === "Install") {
- print.push(command[1]);
- }
- if (print.includes(command[1]) && command[0] === "Uninstall") {
- print.splice(print.indexOf(command[1]), 1);
- }
- if (print.includes(command[1]) && command[0] === "Update") {
- print.push(print.splice(print.indexOf(command[1]), 1));
- }
- if(command[0] === "Expansion") {
- let exp = command[1].split("-");
- if(print.includes(exp[0])) {
- print.splice(print.indexOf(exp[0]) + 1, 0, exp.join(":"));
- }
- }
- }
- console.log(print.join(" "));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement