Loading...

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

koki1234 avatar koki1234 4 Точки

07. Hells Kitchen

Здравейте, 

Закъсал съм с тази задачка и не мога да намеря откъде идва грешката. В Джъдж получавам 72/100, три теста гърмят. Ще се радвам на съдействие :)

https://pastebin.com/NjaaSnTN

1.Hell's Kitchen

You will be given an array of strings, which represents a list of all the restaurants with their workers.

When the [Send] button is clicked:

  • Display the best restaurant of all the added restaurants with its average salary and best salary.
  • If there is a restaurant in the input array that is added more than once, you need to add new workers to the old ones and update the values of the average salary and the best salary.
  • The best restaurant is the restaurant with the highest average salary. If two restaurants have the same average salary the best restaurant is the first one added.
  • Display all workers in the best restaurant with their salaries.

The best restaurant's workers should be sorted by their salaries in descending order.

Input

The input will be received from the given textarea in the form of an array of strings. Each string represents a restaurant with its workers: ["Mikes - Steve 1000, Ivan 200, Paul 800", "Fleet - Maria 850, Janet 650"]

Output

  • The output contains two strings
    • The first one is the best restaurant in the format:

`Name: {restaurant name} Average Salary: {restaurant avgSalary} Best Salary: {restaurant bestSalary}`

avgSalary and bestSalary must be formatted to the second decimal point.

  • The second one is all the workers in that restaurant in the following format:

`Name: {worker name} With Salary: {worker salary} Name: {worker2 name} With Salary: {worker2 salary} Name: {worker3 name} With Salary: {worker3 salary}…

Constraints

  • The workers will be always unique

Examples

Input

Output

Comment

["PizzaHut - Peter 500, George 300, Mark 800",

"TheLake - Bob 1300, Joe 780, Jane 660"]
 

Name: TheLake Average Salary: 913.33 Best Salary: 1300.00
Name: Bob With
Salary: 1300 Name: Joe With Salary: 780 Name: Jane With Salary: 660

The added restaurants are: TheLake and PizzaHut.
TheLake has average salary:
(1300+780+660)/3= 913.33,
and PizzaHub has average salary:
(500+300+800)/2=533.33.
So the best restaurant is TheLake.

["Mikes - Steve 1000, Ivan 200, Paul 800","Fleet - Maria 850, Janet 650"]

Name: Fleet Average Salary: 750.00 Best Salary: 850.00
Name: Maria With Salary: 850 Name: Janet With Salary: 650

 

Тагове:
1
JavaScript Advanced
MartinBG avatar MartinBG 4803 Точки
Best Answer

Не е изпълнено това условие от задачата:

  • If there is a restaurant in the input array that is added more than once, you need to add new workers to the old ones and update the values of the average salary and the best salary.

 Object.assign() не е подходящ в случая и липсва сортировката на служителите след добавянето им към съществуващ ресторант

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