Matched hw1 solution by ctb