6 kyu

Bonuses

663 of 1,435g964

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.
Fundamentals

Stats:

CreatedAug 30, 2019
PublishedAug 30, 2019
Warriors Trained6818
Total Skips356
Total Code Submissions9199
Total Times Completed1435
Python Completions663
CoffeeScript Completions9
Crystal Completions7
Dart Completions71
Java Completions215
Haskell Completions33
C Completions62
JavaScript Completions397
Pascal Completions6
Raku Completions6
Lua Completions29
Perl Completions11
Elm Completions4
D Completions5
Erlang Completions7
Prolog Completions9
Total Stars190
% of votes with a positive feedback rating79% of 237
Total "Very Satisfied" Votes165
Total "Somewhat Satisfied" Votes45
Total "Not Satisfied" Votes27
Total Rank Assessments20
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • g964 Avatar
  • kazk Avatar
  • JohanWiltink Avatar
  • rowcased Avatar
  • monadius Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • user8436785 Avatar
Ad