      "* ' foo bar ' -> '%20foo%20bar%20'\n",
      "* 'foo' -> 'foo'"
     ]
    },
    {
     "cell_type": "code",
     "execution_count": null,
     "metadata": {
      "collapsed": true
     },
     "outputs": [],
     "source": [
      "from nose.tools import assert_equal\n",
      "\n",
      "class Test(object):\n",
      "    def test_replace_char(self, func):\n",
      "        str0 = None\n",
      "        str1 = bytearray(' ||')\n",
      "        str2 = bytearray(' foo bar ||||||')\n",
      "        str3 = bytearray('foo')\n",
      "        func(str0, 0)\n",
      "        func(str1, 1)\n",
      "        func(str2, 9)\n",
      "        func(str3, 3)\n",
      "        assert_equal(str0, None)\n",
      "        assert_equal(str1, '%20')\n",
      "        assert_equal(str2, '%20foo%20bar%20')\n",
      "        assert_equal(str3, 'foo')\n",
      "\n",
      "def run_tests(func):\n",
      "    test = Test()\n",
      "    test.test_replace_char(func)"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Algorithm\n",
 
</s> remove     "            new_length -= 1\n",
    "\n",
    "run_tests(encode_spaces)"
 </s> add     "            new_length -= 1" </s> remove    "execution_count": null,
 </s> add    "execution_count": 2, </s> remove    "execution_count": null,
 </s> add    "execution_count": 1, </s> remove     "            string[new_length - 1] = '2'\n",
    "            string[new_length - 2] = '%'\n",
 </s> add     "            string[new_length-1] = '2'\n",
    "            string[new_length-2] = '%'\n",
      "* ' foo bar ' -> '%20foo%20bar%20'\n",
      "* 'foo' -> 'foo'"
     ]
    },






























    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Algorithm\n",
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Reworked notebook: Added more detail to clarifying questions and test cases.  Reworked algorithm discussion, code, and unit test. 
arrays-strings/replace_char.ipynb