Thoughtworks interview question

Please explain how you solve the assignment.