Solution for runlength problem