mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
Fix #13, PEP8-ify notebooks.
This commit is contained in:
parent
235b6c5abe
commit
4566d1a803
|
@ -88,6 +88,7 @@
|
||||||
"num_items = 10\n",
|
"num_items = 10\n",
|
||||||
"cache = [None] * (num_items + 1)\n",
|
"cache = [None] * (num_items + 1)\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def fib_dynamic(n):\n",
|
"def fib_dynamic(n):\n",
|
||||||
" # TODO: Implement me\n",
|
" # TODO: Implement me\n",
|
||||||
" pass"
|
" pass"
|
||||||
|
@ -139,12 +140,14 @@
|
||||||
" assert_equal(result, fib_seq)\n",
|
" assert_equal(result, fib_seq)\n",
|
||||||
" print('Success: test_fib')\n",
|
" print('Success: test_fib')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestFib()\n",
|
" test = TestFib()\n",
|
||||||
" test.test_fib(fib_recursive)\n",
|
" test.test_fib(fib_recursive)\n",
|
||||||
" test.test_fib(fib_dynamic)\n",
|
" test.test_fib(fib_dynamic)\n",
|
||||||
" test.test_fib(fib_iterative)\n",
|
" test.test_fib(fib_iterative)\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|
|
@ -96,6 +96,7 @@
|
||||||
"num_items = 10\n",
|
"num_items = 10\n",
|
||||||
"cache = [None] * (num_items + 1)\n",
|
"cache = [None] * (num_items + 1)\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def fib_dynamic(n):\n",
|
"def fib_dynamic(n):\n",
|
||||||
" if n == 0 or n == 1:\n",
|
" if n == 0 or n == 1:\n",
|
||||||
" return n\n",
|
" return n\n",
|
||||||
|
@ -159,12 +160,14 @@
|
||||||
" assert_equal(result, fib_seq)\n",
|
" assert_equal(result, fib_seq)\n",
|
||||||
" print('Success: test_fib')\n",
|
" print('Success: test_fib')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def main():\n",
|
"def main():\n",
|
||||||
" test = TestFib()\n",
|
" test = TestFib()\n",
|
||||||
" test.test_fib(fib_recursive)\n",
|
" test.test_fib(fib_recursive)\n",
|
||||||
" test.test_fib(fib_dynamic)\n",
|
" test.test_fib(fib_dynamic)\n",
|
||||||
" test.test_fib(fib_iterative)\n",
|
" test.test_fib(fib_iterative)\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"if __name__ == '__main__':\n",
|
"if __name__ == '__main__':\n",
|
||||||
" main()"
|
" main()"
|
||||||
]
|
]
|
||||||
|
|
|
@ -11,11 +11,13 @@ class TestFib(object):
|
||||||
assert_equal(result, fib_seq)
|
assert_equal(result, fib_seq)
|
||||||
print('Success: test_fib')
|
print('Success: test_fib')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
test = TestFib()
|
test = TestFib()
|
||||||
test.test_fib(fib_recursive)
|
test.test_fib(fib_recursive)
|
||||||
test.test_fib(fib_dynamic)
|
test.test_fib(fib_dynamic)
|
||||||
test.test_fib(fib_iterative)
|
test.test_fib(fib_iterative)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
Loading…
Reference in New Issue
Block a user