Ask Your Question

Revision history [back]

Well, I wrote this shorter code :

#PB: Maxime is 32 years old.
#It is twice as old as Albane was when he was the age Albane has now.
#What is Albane's age?
# m = age of Maxime a = age of Albane, x = age difference   
var ('m, x, a')
e1 = m - a == x
e2 = m == 2 * (a-x)
solution = solve([e1,e2],x,a) 
print 'the age of Albane is', solution[0][1].rhs().subs(m=32)

The output is :

$\left[x = \frac{1}{4} \, m, a = \frac{3}{4} \, m\right]$

the age of Albane is 24