Completed ruby exercise 18.