You're a plumber working on a house, and there's some pipes that must be connected at weird angles. You have 8°, 11.25°, 22.5°, 45°, and 90° fittings at your disposal, and you want to use as few as possible to match the angle as closely as possible.
- Match the desired angle as closely as possible, with as few fittings as possible. It can be over or under the desired angle.
- Accuracy is more important than the number of fittings
- In the case of two different sets of fittings with the same resulting angle, whichever has the fewest number of fittings should be selected.
- If the two sets use different fittings, match the same angle, and have the same number of fittings, either may be chosen.
- Your fittings cannot add up to greater than 360 degrees (i.e. no looping all the way around)
Your input is a random integer between (non-inclusive) 0° and 180°, which represents the desired angle.
Your output should be an array where -># of 8° fittings, -># of 11.25° fittings, etc. If your language does not support arrays, you may output a comma separated list, where the first value represents the number of 8° fittings, and so on and so forth.
90° ->[0,0,0,0,1] 24°-> [3,0,0,0,0] ([0,0,1,0,0] uses less fittings, but is less accurate and therefore incorrect) 140°->[2,1,1,0,1] 140°->"2,1,1,0,1" acceptable if language does not support arrays
Lowest byte count for each language wins a high five from me if we ever bump into each other (and the challenge).