Нужда от помощ за задача 09. Tseam Account - Arrays - JavaScript
Здравейте, имам затруднение с тази задача. Стигам донякъде и не мога напред. Ако може някой да ми пусне готов код, за да се ориетирам - благодаря предварително. А пък, ако има време и нерви да ми види кода, ще съм два пъти по-благодарна. Проблемът ми е в сравняването на стринговете при операцията Expansion. Не съм наясно как да го направя. Опитвам се да реша задачата по уж алгоритмичен начин, а не с готови функции, които не са преподавани все още в напредлала фаза.
https://pastebin.com/isqW4bLm
As a gamer, Pesho has Tseam Account. He loves to buy new games. You are given Pesho's account with all of his games-> strings, separated by space. Until you receive "Play!" you will be receiving commands which Pesho 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 Pesho`s account – sequence of game names, separated by space.
- Until you receive "Play!" you will be receiving commands.
Output
- As output you must print Pesho`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 |
Comment |
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 |
|