Bonuses
Description:
John wants to give a total bonus of $851
to his three employees taking fairly as possible into account their number of days of absence during the period under consideration.
Employee A was absent 18
days, B 15
days, and C 12
days.
The more absences, the lower the bonus ...
How much should each employee receive?
John thinks A should receive $230
, B $276
, C $345
since 230 * 18 = 276 * 15 = 345 * 12
and 230 + 276 + 345 = 851
.
Task:
Given an array arr
(numbers of days of absence for each employee) and a number s
(total bonus) the function bonus(arr, s)
will follow John's way and return an array of the fair bonuses of all employees in the same order as their numbers of days of absences.
s
and all elements of arr
are positive integers.
Examples:
bonus([18, 15, 12], 851) -> [230, 276, 345]
bonus([30, 27, 8, 14, 7], 34067) -> [2772, 3080, 10395, 5940, 11880]
Notes
- See Example Test Cases for more examples.
- Please ask before translating.
- In some tests the number of elements of
arr
can be big.
Similar Kata:
Stats:
Created | Aug 30, 2019 |
Published | Aug 30, 2019 |
Warriors Trained | 6818 |
Total Skips | 356 |
Total Code Submissions | 9199 |
Total Times Completed | 1435 |
Python Completions | 663 |
CoffeeScript Completions | 9 |
Crystal Completions | 7 |
Dart Completions | 71 |
Java Completions | 215 |
Haskell Completions | 33 |
C Completions | 62 |
JavaScript Completions | 397 |
Pascal Completions | 6 |
Raku Completions | 6 |
Lua Completions | 29 |
Perl Completions | 11 |
Elm Completions | 4 |
D Completions | 5 |
Erlang Completions | 7 |
Prolog Completions | 9 |
Total Stars | 190 |
% of votes with a positive feedback rating | 79% of 237 |
Total "Very Satisfied" Votes | 165 |
Total "Somewhat Satisfied" Votes | 45 |
Total "Not Satisfied" Votes | 27 |
Total Rank Assessments | 20 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 8 kyu |