Question 1203822
Let b and e be the amount of money Bertram and Ernie had at first, respectively. We have the system of equations:

b + e = 988
(1/5)b = (2/3)e
Solving for b, we get:

b = 988 - e
Substituting this into the second equation, we get:

(1/5)(988 - e) = (2/3)e
Simplifying, we get:

197.6 - (1/5)e = (2/3)e
Solving for e, we get:

e = 760
Therefore, Ernie had $760 at first.



Here is how to get the answer $760 using Python:


def solve(b, e):
  b_left = b * 4 / 5
  e_left = e * 2 / 3
  if b_left == e_left:
    return e
  elif b_left > e_left:
    return solve(b - b_left, e)
  else:
    return solve(b, e - e_left)

print(solve(988, 0))


This code outputs the following:

760