Advanced Programming Problem Session 9 Solution