You're solving a simple Diophantine equation and you use the following Python code to do it.
## 3a+b+c+d=10
r=10/3
for a in range(r, 0, -1):
r=10-3*a
for b in range(r, 0, -1):
r=10-3*a-b
for c in range(r, 0, -1):
d=10-3*a-b-c
if d>0:
print a, b, c, d, 3*a + b + c + d
While preserving the essential character of the code how would you represent it 'nicely' so that it extends to provide for more variables in the Diophantine equation?
There are nine solutions:
1 6 1
1 5 2
1 4 3
1 3 4
1 2 5
1 1 6
2 3 1
2 2 2
2 1 3