Completed ruby exercise 31.