Weighing on scales with pans (easy)
Description:
Laura and Sarah Kraft are treasure hunter twins. After another successful journey, they obtained several pieces of gold ore and one large figurine covered with mystical writings.
They had with them electronic and mechanical scales. They weighed and found out the exact weight of each piece of gold ore, but the figurine was too large and could not be weighed on an electronic scale.
The mystical inscription on the figurine said that its weight is equal to the holy number N. Then the twins decided to check whether this statement was true using mechanical scales.
Help the twins set the pieces of ore on the scales in such a way that the scales come into balance after you place the figurine on the right pane (assuming that the figurine really weighs N).
Inputs:
- weights - an array of weights for pieces of gold ore
- N - the holy number, the weight of the figurine placed on the right pan
The output should be an array describing the pans: [left, right], the left and right are the weight arrays of the pieces of gold ore placed on the respective pan. Obviously, each piece can only be used once. Although not all pieces must be used.
For example, suppose that pieces of gold ore weigh [1, 2, 7]
for N = 3 the output should be [[1, 2],[]]
for N = 5 the output should be [[7],[2]]
If the scale cannot be balanced, an empty array should be returned.
For this (easy) version, the number of ore pieces is no more than 10. If you have done with this kata, try Weighing on scales with pans (advanced) version.
Similar Kata:
Stats:
Created | Jun 19, 2022 |
Published | Jun 19, 2022 |
Warriors Trained | 284 |
Total Skips | 69 |
Total Code Submissions | 211 |
Total Times Completed | 31 |
JavaScript Completions | 26 |
Python Completions | 8 |
Total Stars | 6 |
% of votes with a positive feedback rating | 100% of 13 |
Total "Very Satisfied" Votes | 13 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 6 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |