A drug comes in 5mg, 2.5mg, and 1mg sized pills. The drug is taken once a day. The total daily dose will be only one of the following (all in mg):
1, 2, 3, ... 20, 22.5, 25, 27.5, 30, 32.5, 35, 37.5, 40, 42.5, 45, 47.5, 50
In words: any whole number less or equal to 20, then at 2.5mg increments up to 50.
Your task is to determine how many pills of each size the patient should take to get to their total dose, minimizing the total number of pills they have to take.
Input: the total daily dose
Output: the respective number of 5mg, 2.5mg, and 1mg the patient needs to take, in any consistent format.
This is code golf. Fewest number of bytes wins.
Examples: (output is number of 1, 2.5, and 5 mg pills)
1 => [1, 0, 0]
4 => [4, 0, 0]
7 => [2, 0, 1]
19 => [4, 0, 3]
22.5 => [0, 1, 4]
40 => [0, 0, 8]
Irrelevant: this is based on a true story. The drug is prednisone and I wrote a program to automate the production of a calendar for patients to use to titrate their doses, which is a challenging task for many elderly patients to do safely even if you give them written instructions. This challenge was part of the programming task.