protected static function group($string)
    {
        $grouped = [];
        $chars = str_split($string);

        $prevChar = null;
        $i = 0;
        foreach ($chars as $char) {
            if ($prevChar === $char) {
                $grouped[$i - 1] .= $char;
            } else {
                $grouped[$i] = $char;
                ++$i;
                $prevChar = $char;
            }
        }

        return $grouped;
    }