Fix #13, PEP8-ify notebooks.

This commit is contained in:
Donne Martin
2015-07-11 15:34:14 -04:00
parent 27c4a4f97c
commit 374d67ff30
18 changed files with 117 additions and 80 deletions

View File

@@ -100,7 +100,7 @@
"def compress_string(string):\n",
" if string is None or len(string) == 0:\n",
" return string\n",
" \n",
"\n",
" # Calculate the size of the compressed string\n",
" size = 0\n",
" last_char = string[0]\n",
@@ -109,8 +109,8 @@
" size += 2\n",
" last_char = char\n",
" size += 2\n",
" \n",
" # If the compressed string size is greater than \n",
"\n",
" # If the compressed string size is greater than\n",
" # or equal to string size, return original string\n",
" if size >= len(string):\n",
" return string\n",
@@ -129,7 +129,7 @@
" last_char = char\n",
" compressed_string.append(last_char)\n",
" compressed_string.append(str(count))\n",
" \n",
"\n",
" # Convert the characters in the list to a string\n",
" return \"\".join(compressed_string)"
]
@@ -162,7 +162,7 @@
"\n",
"\n",
"class TestCompress(object):\n",
" \n",
"\n",
" def test_compress(self, func):\n",
" assert_equal(func(None), None)\n",
" assert_equal(func(''), '')\n",
@@ -170,10 +170,12 @@
" assert_equal(func('AAABCCDDDD'), 'A3B1C2D4')\n",
" print('Success: test_compress')\n",
"\n",
"\n",
"def main():\n",
" test = TestCompress()\n",
" test.test_compress(compress_string)\n",
"\n",
"\n",
"if __name__ == '__main__':\n",
" main()"
]