Build an Algorithm
Budget: $100 – $125 USD
I need an algorithm written in PHP as a function. It needs to accept a single positive number of any size as the input. It needs to divide the input by 4, by 8 or by both 4 and 8 to use as much of the input as possible without going over it value. Example if the input was 28. The output could be any of the following:
3 parts 8 and 1 part 4;
7 parts 4 ;
2 parts 8 and 3 parts 4;
1 part 8 and 5 parts 4;
etc..
If the input was 29, all the same results could be provided as were for 28 with a suggestion to add 3.
If the input was 27, all the same results could be provided as were for 28 with a suggestion to add 1.
I the case of a suggestion to add to the input, the suggestion should not exceed 3.
The goal result is provide how many time 4, or 8 or a combination of both can be derived from the input.
3 parts 8 and 1 part 4;
7 parts 4 ;
2 parts 8 and 3 parts 4;
1 part 8 and 5 parts 4;
etc..
If the input was 29, all the same results could be provided as were for 28 with a suggestion to add 3.
If the input was 27, all the same results could be provided as were for 28 with a suggestion to add 1.
I the case of a suggestion to add to the input, the suggestion should not exceed 3.
The goal result is provide how many time 4, or 8 or a combination of both can be derived from the input.