There is probably an algorithm for this, but I'm not sure what it is.
For an integer X, what are the fewest number of integers whose sum is X, and where the summed integers are less or equal to Y and can be repeated in the sum.
For example:
X=95
Y=1
This is 1 (95 times)
X=39
Y=5
This is 5 (7 times) and 4 (1 time)
X=53
Y=11
This is 11 (4 times), 9 (1 time)
I see that this is kind of recursively dividing the value while reducing the denominator until reaching zero, but there is probably a more elegant method.
UPDATE:
Two things:
- I didn't realize that there would not be more than 1 level of division required for this. I assumed that there could be a combination of numerator/denominator where there would be remainders after the 2nd occurrence of the division, but at least in my use case, there isn't.
- No, there is nothing Python-specific, it's just what I was using.