My solution for a class assignment.