This first program solves a problem that was set as one of the programming problems for the final Programming Contest of the Educational Computing Organization of Ontario (ECOO) which involved teams from Ontario highschools. The problem description and Java solution can be found: here. The Miranda solution can be found here.