      "    for char in string:\n",
      "        if char == prev_char:\n",
      "            count += 1\n",
      "        else:\n",
      "            result += prev_char + str(count)\n",
      "            prev_char = char\n",
      "            count = 1\n",
      "    result += prev_char + str(count)\n",
      "    return result if len(result) < len(string) else string"
     ]
 
</s> remove     "        assert_equal(func('AAABCCDDDD'), 'A3B1C2D4')\n",
 </s> add     "        assert_equal(func('AAABCCDDDD'), 'A3BC2D4')\n", </s> remove     "## Problem: Compress a string such that 'AAABCCDDDD' becomes 'A3B1C2D4'.  Only compress the string if it saves space.\n",
 </s> add     "## Problem: Compress a string such that 'AAABCCDDDD' becomes 'A3BC2D4'.  Only compress the string if it saves space.\n", </s> remove         assert_equal(func('AAABCCDDDD'), 'A3B1C2D4')
 </s> add         assert_equal(func('AAABCCDDDD'), 'A3BC2D4') </s> remove     "* 'AAABCCDDDD' -> 'A3B1C2D4'"
 </s> add     "* 'AAABCCDDDD' -> 'A3BC2D4'"
    "            result += prev_char + (str(count) if count > 1 else '')\n",
      "    for char in string:\n",
      "        if char == prev_char:\n",
      "            count += 1\n",
      "        else:\n",
    "            result += prev_char + (str(count) if count > 1 else '')\n",
      "            prev_char = char\n",
      "            count = 1\n",
      "    result += prev_char + str(count)\n",
      "    return result if len(result) < len(string) else string"
     ]
keep keep keep keep replace keep keep keep keep keep
 Update compress solution so AAAAB becomes A4B.

Previously the solution would yield A4B1, which doesn't have as much compression. 
arrays_strings/compress/compress_solution.ipynb