Homework commit

Finished homework, the output is same as given. Thanks.