5. Tseam Account , Arrays - More Exercise
Някой може ли да помогне с тази задача, защото съвсем се оплетох...
https://pastebin.com/MLSLiUQc
1.Tseam Account
As a gamer, Peter has Tseam Account. He loves to buy new games. You are given Peter's account with all of his games-> strings, separated by space. Until you receive "Play!" you will be receiving commands which Peter does with his account.`
You may receive the following commands:
- Install {game}
- Uninstall {game}
- Update {game}
- Expansion {game}-{expansion}
If you receive Install command, you should add the game at last position in the account, but only if it isn't installed already.
If you receive Uninstall command, delete the game if it exists.
If you receive Update command, you should update the game if it exists and place it on last position.
If you receive Expansion command, you should check if the game exists and insert after it the expansion in the following format: "{game}:{expansion}";
Input
- On the first input line you will receive Peter`s account - sequence of game names, separated by space.
- Until you receive "Play!" you will be receiving commands.
Output
- As output you must print Peter`s Tseam account.
Constraints
- The command will always be valid.
- The game and expansion will be strings and will contain any character, except '-'.
- Allowed working time / memory: 100ms / 16MB.
Examples
Input |
Output |
Comments |
['CS WoW Diablo', 'Install LoL', 'Uninstall WoW', 'Update Diablo', 'Expansion CS-Go', 'Play!'] |
CS CS:Go LoL Diablo |
We receive the account => CS, WoW, Diablo We Install LoL => CS, WoW, Diablo, LoL Uninstall WoW => CS, Diablo, LoL Update Diablo => CS, LoL, Diablo We add expansion => CS, CS:Go, LoL, Diablo We print the account. |
['CS WoW Diablo', 'Uninstall XCOM', 'Update PeshoGame', 'Update WoW', 'Expansion Civ-V', 'Play!'] |
CS Diablo WoW |
|
Multidimensional Arrays
We will mainly work with 2-dimensional arrays. The concept is as simple as working with a simple 1-dimensional array. It is just an array of arrays.
Благодаря за помощта и за насоките, за пореден път! Знам, че колеги вече са коментирали тази задача, но ме интересуваше дали и моят вариант някак може да се дооправи, и да проработи
Виждам, че задачата може да се реши много по-кратко и ми е много полезно твоето решение да разбера този тип задачи!