Description:
Your colleagues have been looking over you shoulder. When you should have been doing your boring real job, you've been using the work computers to smash in endless hours of codewars.
In a team meeting, a terrible, awful person declares to the group that you aren't working. You're in trouble. You quickly have to gauge the feeling in the room to decide whether or not you should gather your things and leave.
Given an object (meet) containing team member names as keys, and their happiness rating out of 10 as the value, you need to assess the overall happiness rating of the group. If <= 5, return 'Get Out Now!'. Else return 'Nice Work Champ!'.
Happiness rating will be total score / number of people in the room.
Note that your boss is in the room (boss), their score is worth double it's face value (but they are still just one person!).
Solution:
1. Check the score of the boss.
2. Add the score of the remaining members and add the score of the boss one more time.
3. Calculate happiness by averaging the total scores.
4. If the happiness rating is 5 or less, 'Get Out Now!' is returned, otherwise 'Nice Work Champ!' is returned.
def outed(meet, boss):
import math
boss_score = meet.get(boss)
total_score = sum(meet.values()) + boss_score
Happiness_rating = math.ceil(total_score / len(meet))
return ['Nice Work Champ!', 'Get Out Now!'][Happiness_rating <= 5]
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
Two to One (0) | 2022.04.26 |
---|---|
Apparently-Modifying Strings (0) | 2022.04.26 |
Shortest Word (0) | 2022.04.23 |
Vowel Count (0) | 2022.04.22 |
String ends with? (0) | 2022.04.21 |