Solution to problem 1.5 .

Compress a string .