9
\$\begingroup\$

Inspired by the challenge A pile of weights.

Challenge

Given an integer as a weight in pounds, output an ASCII barbell that can represent the weight. Weights will come in the form of the barbell (which will weigh 45lbs) and plates with the following weights: 45lbs, 35lbs, 25lbs, 10lbs, and 5lbs. Weights will be represented as follows:

Barbell:
 ___________                         ___________
|___________|::===================::|___________|

45lbs:    35lbs:     25lbs:    10lbs:    5lbs:
 __         _          
|  |       | |        .-.        _
|  |       | |        | |       | |       .-.
|  |       | |        | |       | |       | |
|  |       | |        | |       |_|       '-'
|__|       |_|        '-'

Rules

•The barbell is always needed, so the minimum weight is 45lbs.

•The weights must be equal on both sides of the barbell. You cannot have a 45lbs plate on one end and only a 25lbs plate on the other.

•The maximum weight is 415lbs. Anything above this would not fit on the barbell.

•Weights will always be loaded so the heaviest weights are on the inside of the barbell.

•You must use the heaviest plates available. To represent 55lbs on one side, you must use the plates (45lbs + 10lbs). Both (25lbs + 10lbs + 10lbs) and (35lbs + 10lbs) are invalid.

•Any input that cannot be represented is considered invalid. You can handle invalid cases if you like by outputting the nearest valid weight, but it is not required.

Test Cases

Input:
45
Output:
 ____________                         ____________
|____________|::===================::|____________|

Input:
135
Output:
           __                         __
          |  |                       |  |
 _________|  |                       |  |_________
|_________|  |::===================::|  |_________|
          |  |                       |  |
          |__|                       |__|

Input:
415
Output:
  __ __ __ __                         __ __ __ __ 
 |  |  |  |  |                       |  |  |  |  |
 |  |  |  |  |                       |  |  |  |  |
||  |  |  |  |::===================::|  |  |  |  ||
 |  |  |  |  |                       |  |  |  |  |
 |__|__|__|__|                       |__|__|__|__|

Input:
175
Output:
           __                         __
       _ _|  |                       |  |_ _
 _____| | |  |                       |  | | |_____
|_____| | |  |::===================::|  | | |_____|
      |_|_|  |                       |  |_|_|
          |__|                       |__|

Input:
105
Output:
           .-.                       .-. 
 ________.-| |                       | |-.________
|________| | |::===================::| | |________|
         '-| |                       | |-'
           '-'                       '-'
Input:
355
Output:

     __ __ __                         __ __ __  
 _ _|  |  |  |                       |  |  |  |_ _
| | |  |  |  |                       |  |  |  | | |
| | |  |  |  |::===================::|  |  |  | | |
|_|_|  |  |  |                       |  |  |  |_|_|
    |__|__|__|                       |__|__|__|

Input:
215
Output:
         _ __                         __ _
        | |  |                       |  | |
 _____.-| |  |                       |  | |-._____
|_____| | |  |::===================::|  | | |_____|
      '-| |  |                       |  | |-'
        |_|__|                       |__|_|   
\$\endgroup\$
  • \$\begingroup\$ As my first challenge, recommendations to improve wording or address something I've missed are welcome. \$\endgroup\$ – tgrass12 Apr 27 '18 at 19:15
  • \$\begingroup\$ Similar challenge found here. \$\endgroup\$ – tgrass12 Apr 27 '18 at 19:17
  • \$\begingroup\$ I feel like this is too similar to these existing questions. Try coming up with an entirely new challenge idea. \$\endgroup\$ – mbomb007 Apr 27 '18 at 19:27
  • 8
    \$\begingroup\$ Don't be discouraged though, this was a well-formed question that already existed. You did a wonderful job including needed information and got no downvotes. That's amazingly good compared to most first asked questions :). \$\endgroup\$ – Magic Octopus Urn Apr 27 '18 at 20:41

Browse other questions tagged or ask your own question.