A=#pupils in hall A
B=#pupils in hall B
If 14 pupils leave A, there are
A-14 pupils left in A.
If they go to hall B, there are then
B+14 pupils in hall B.
Those being the same numbers means:
A-14=B+14
If 4 pupils leave B, there are then
B-4 pupils left in hall B.
If those 4 go to hall A, there are then
A+4 pupils in hall A.
Ratio is 8:5 means
A+4 : B-4 = 8:5
So we have 2 equations with 2 variables:
1)A-14=B+14
2)(A+4) :( B-4) = 8:5
Solve for A and B:
(A+4):(B-4)=8:5
<=>
(A+4)5=(B-4)8
<=>
5A+20=8B-32
<=>
5A-8B=-52
So we have 2 linear equations:
- A-14=B+14
- 5A-8B=-52
Solve 1 for A.
A=B+28
Plug A into 2):
5(B+28)-8B=-52
<=>
5B+140-8B=-52
<=>
-3B=-192
<=>
B=192/3=64