I want to know the possible combinations in code/algorithm for three numbers with an increment of 5 and a total of 100. See examples below.
5 10 85
5 15 80
5 20 75
.
.
10 15 75
Thank you.
I want to know the possible combinations in code/algorithm for three numbers with an increment of 5 and a total of 100. See examples below.
5 10 85
5 15 80
5 20 75
.
.
10 15 75
Thank you.
Get all possible combinations and check if the sum is 100.
In code it looks like this:
import itertools
base = range(5, 100, 5)
combis = itertools.combinations(base, 3)
for values in combis:
if sum(values) == 100:
print(values)
This gives you all results. You should have no problems to count them.
If you want to learn try it without itertools.