You need to sign in or sign up before continuing.×
6 kyu

Weight assistant

Description:

Hi everyone!

At a powerlifting competition, there are 2 assistants who assemble the barbell for the athletes. Each of them is responsible for their part of the bar. Write a function assistance(weight) that outputs which disks and in what order should be hung on each end of the bar.

Rules

Weight of barbell = 20 kg
lock = 2.5kg

Available disks:

red = 25 kg
blue = 20 kg
yellow = 15 kg
green = 10 kg
black = 5 kg
orange = 2.5 kg
white = 1.25 kg

The number of disks is not limited.

The heaviest disks are always hung at the beginning, and the lightest disks are hung at the end.

If you can hang a minimum number of weights on the bar in several ways, then choose the method that has heavier weights. (Check the last example)

Also you have a lock that weight 2.5 kg. If there is at least one disk on the neck, then there must be a lock hanging at the end of bar.

If you can't hang the required weight, display "Error".

Inputs

You have access to one value - the weight of the bar in kg. Weight can be float.

0 < weight < 500

Examples

0 => "Error" (Because it's lower that minimum weight (20 kg))
20 => "Nothing to hang" (Because bar weight 20 kg already)
22.5 => "Error" (You can't hang disks without locks)
25 => "Only lock" (Because they weight 2.5 kg)
30 => "1 orange, lock"
35 => "1 black, lock"
50 => "1 green, 1 orange, lock"
65 => "1 blue, lock"
100 => "1 red, 1 green, 1 orange, lock"
102.5 => "1 red, 1 green, 1 orange, 1 white, lock"
103 => "Error"
345 => "6 reds, 1 green, lock" (If there are several pancakes, then it should be written in the plural)
105 => "1 red, 1 yellow, lock" ("You can't hang 2 blue and a lock because the red one is heavier than the blue one.")

Good luck!

Strings

Stats:

CreatedSep 8, 2024
PublishedSep 8, 2024
Warriors Trained148
Total Skips10
Total Code Submissions203
Total Times Completed65
Python Completions65
Total Stars5
% of votes with a positive feedback rating87% of 23
Total "Very Satisfied" Votes17
Total "Somewhat Satisfied" Votes6
Total "Not Satisfied" Votes0
Total Rank Assessments13
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • KiLeX Avatar
  • dfhwze Avatar
Ad