Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

AlexanderF avatar AlexanderF 1 Точки

Arena Tier 90/100

Не мота да разбера грешката, дори и 2рия zero тест не минава в judge, а в vscode получавам правилен output?!

Output-а на кода в vscode е различен от output-а на същия код поставен в judge.

https://pastebin.com/897cMGks

Условие:

9. *Arena Tier

Pesho is a pro gladiator, he is struggling to become master of the Arena.

You will receive several input lines in one of the following formats:

"{gladiator} -> {technique} -> {skill}"

"{gladiator} vs {gladiator}"

The gladiator and technique are strings, the given skill will be an integer number. You need to keep track of every gladiator.

When you receive a gladiator and his technique and skill, add him to the gladiator pool, if he isn't present, else add his technique or update his skill, only if the current technique skill is lower than the new value.

If you receive "{gladiator} vs {gladiator}" and both gladiators exist in the tier, they duel with the following rules:

Compare their techniques, if they got at least one in common, the gladiator with better total skill points wins and the other is demoted from the tier -> remove him.

If they don't have techniques in common, the duel isn't happening and both continue in the Season.

You should end your program when you receive the command "Ave Cesar". At that point you should print the gladiators, ordered by total skill in desecending order, then ordered by name in ascending order. Foreach gladiator print their technique and skill, ordered desecending, then ordered by technique name in ascending order

Input / Constraints

You will receive an array of strings as a parameter to your solution.

  • The input comes in the form of commands in one of the formats specified above.
  • Gladiator and technique will always be one word string, containing no whitespaces.
  • Skill will be an integer in the range [0, 1000].
  • There will be no invalid input lines.
  • The programm ends when you receive the command "Ave Cesar".
     

Output

  • The output format for each gladiator is:

"{gladiator}: {totalSkill} skill"

"- {technique} <!> {skill}"

Scroll down to see examples.

Examples

Input

Output

Comments

[

'Peter -> BattleCry -> 400',

'Alex -> PowerPunch -> 300',

'Stefan -> Duck -> 200',

'Stefan -> Tiger -> 250',

'Ave Cesar'

]

Stefan: 450 skill

- Tiger <!> 250

- Duck <!> 200

Peter: 400 skill

- BattleCry <!> 400

Alex: 300 skill

- PowerPunch <!> 300

We order the gladiators by total skill points descending, then by name. We print every technique along its skill ordered descending by skill, then by technique name.

Input

Output

 

[

'Pesho -> Duck -> 400',

'Julius -> Shield -> 150',

'Gladius -> Heal -> 200',

'Gladius -> Support -> 250',

'Gladius -> Shield -> 250',

'Peter vs Gladius',

'Gladius vs Julius',

'Gladius vs Maximilian',

'Ave Cesar'

]

Gladius: 700 skill

- Shield <!> 250

- Support <!> 250

- Heal <!> 200

Peter: 400 skill

- Duck <!> 400

Gladius and Peter don't have common technique, so the duel isn't valid.

Gladius wins vs Julius /common technique: "Shield". Julius is demoted.

Maximilian doesn't exist so the duel isn't valid.

We print every gladiator left in the tier.

Тагове:
0
JavaScript Fundamentals
krasizorbov avatar krasizorbov 548 Точки

Ето едно примерно решение за сравнение понеже нямам време да разгледам твоето. Лесно ще си откриеш грешката.

https://pastebin.com/2hhgXiVF

0
15/07/2020 23:02:55
v.vachev avatar v.vachev 14 Точки

Ето и едно решение с map -> https://pastebin.com/bhtjqbE3

Все пак с object май си е по-добре : ) 

В решението в Word има грешка спрямо сортирането на техниките. Judge ги иска сортирани по описания начин: 

. Foreach gladiator print their technique and skill, ordered desecending, then ordered by technique name in ascending order

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.