Beginners String Problem solution