Finished homework

Finished homework, could have polished it more, but it works.