Solving a small programming challenge from Machinalis