Find a solution to the equation:
29x + 30y + 31z = 366
Rem: x,y,z must be positive
I never thought of the relationship of the problem to days of the month until I read Charlie's post.
I actually looked after I leaped and started with a short Python program (see below) that found the two solutions:
(x,y,z) = (1,4,7) or (2,2,8)
But then I noticed that since 29, 30, and 31 are so close together, if x y and z must be positive integers then x+y+z must be 12. And since the sum is 366 rather than 360, z must be 6 larger than x.
So if z = x+6, and y = 12-x-z, then y=12-x-(x+6) = 6-2x.
So to make a table of possible values:
x, y=6-2x, z=x+6
0 6 6
1 4 7
2 2 8
3 0 9
throw out the ones with zeros, and poof! Done! That was fast.
Formally proving the above.
29x + 30y + 31z = 366
30(x+y+z) - x + z = 366
x+y+z = 12
360 - x + z = 366
z = x+6
----- Python program
n=13
for x in range(1,n):
for y in range(1,n):
for z in range(1,n):
if 29*x + 30*y + 31*z == 366:
print(x,y,z,29*x + 30*y + 31*z)
|
Posted by Larry
on 2020-10-03 10:34:46 |