Beta

Justice Always Wins

Description:

Story

Once upon a time, there lived 5 sons, and under one sunny day they decided to walk and make purchases for the amount of 2200. The first son Rakhat bought himself a T-shirt for 500, the second son Almat bought himself sneakers for 850, the third son Bekzat bought himself shorts for 370, the fourth son Samat thought about his mother and bought her flowers for 320, the fifth Dias turned out to be smart and bought himself only a chocolate bar for 160. To make it fair, everyone decided to divide the money evenly and those who spent more earned and gave it to those who did not spend. Also they decided that it makes no sense to be niggling, so they will round everything up to the nearest ten.

Task

You have to decide who owes whom, how much?

Format

  • Floating numbers are not considered in this task
  • If amount equal to 4 round up to 0, else if it equal to 5, then round up to 10.

Input:

  • object of any number of persons
    {
      Rakhat: 500,
      Almat: 850,
      Bekzat: 370,
      Samat: 320,
      Dias: 160
    }
    

Output:

  • Array of arrays, where first is the borrower of second for the third amount
  • Sort ascending order by amount
    [
      [ 'Bekzat', 'Almat', 10 ],
      [ 'Bekzat', 'Rakhat', 60 ],
      [ 'Samat', 'Almat', 120 ],
      [ 'Dias', 'Almat', 280 ]
    ]
    
Fundamentals

Stats:

CreatedNov 7, 2021
PublishedNov 7, 2021
Warriors Trained29
Total Skips0
Total Code Submissions151
Total Times Completed7
JavaScript Completions7
Total Stars1
% of votes with a positive feedback rating25% of 4
Total "Very Satisfied" Votes0
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes2
Total Rank Assessments4
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • ZhumanRakhat Avatar
Ad