mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-10 03:18:02 +00:00
Fix #13, PEP8-ify notebooks.
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
|
||||
"* Can I assume the string is ASCII?\n",
|
||||
" * Yes\n",
|
||||
" * Note: Unicode strings could require special handling depending on your language\n",
|
||||
@@ -113,18 +112,21 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestReverse(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def test_reverse(self):\n",
|
||||
" assert_equal(list_of_chars(None), None)\n",
|
||||
" assert_equal(list_of_chars(['']), [''])\n",
|
||||
" assert_equal(list_of_chars(['f', 'o', 'o', ' ', 'b', 'a', 'r']), \n",
|
||||
" ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n",
|
||||
" assert_equal(list_of_chars(\n",
|
||||
" ['f', 'o', 'o', ' ', 'b', 'a', 'r']),\n",
|
||||
" ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n",
|
||||
" print('Success: test_reverse')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestReverse()\n",
|
||||
" test.test_reverse()\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
@@ -126,9 +126,10 @@
|
||||
" return None\n",
|
||||
" return string[::-1]\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def reverse_string_alt2(string):\n",
|
||||
" if string is None:\n",
|
||||
" return None \n",
|
||||
" return None\n",
|
||||
" return ''.join(reversed(string))"
|
||||
]
|
||||
},
|
||||
@@ -160,18 +161,21 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestReverse(object):\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def test_reverse(self):\n",
|
||||
" assert_equal(list_of_chars(None), None)\n",
|
||||
" assert_equal(list_of_chars(['']), [''])\n",
|
||||
" assert_equal(list_of_chars(['f', 'o', 'o', ' ', 'b', 'a', 'r']), \n",
|
||||
" ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n",
|
||||
" assert_equal(list_of_chars(\n",
|
||||
" ['f', 'o', 'o', ' ', 'b', 'a', 'r']),\n",
|
||||
" ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n",
|
||||
" print('Success: test_reverse')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def main():\n",
|
||||
" test = TestReverse()\n",
|
||||
" test.test_reverse()\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == '__main__':\n",
|
||||
" main()"
|
||||
]
|
||||
|
||||
@@ -2,17 +2,20 @@ from nose.tools import assert_equal
|
||||
|
||||
|
||||
class TestReverse(object):
|
||||
|
||||
|
||||
def test_reverse(self):
|
||||
assert_equal(list_of_chars(None), None)
|
||||
assert_equal(list_of_chars(['']), [''])
|
||||
assert_equal(list_of_chars(['f', 'o', 'o', ' ', 'b', 'a', 'r']),
|
||||
['r', 'a', 'b', ' ', 'o', 'o', 'f'])
|
||||
assert_equal(list_of_chars(
|
||||
['f', 'o', 'o', ' ', 'b', 'a', 'r']),
|
||||
['r', 'a', 'b', ' ', 'o', 'o', 'f'])
|
||||
print('Success: test_reverse')
|
||||
|
||||
|
||||
def main():
|
||||
test = TestReverse()
|
||||
test.test_reverse()
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user