basic string compression, 1.5 from "Cracking the Coding Interview"