Solving practice problems with Ruby