From 4566d1a803bbe8b1bca8096b1f853e0648ef99ed Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Sat, 11 Jul 2015 15:35:34 -0400 Subject: [PATCH] Fix #13, PEP8-ify notebooks. --- recursion_dynamic/fibonacci/fibonacci_challenge.ipynb | 5 ++++- recursion_dynamic/fibonacci/fibonacci_solution.ipynb | 7 +++++-- recursion_dynamic/fibonacci/test_fibonacci.py | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/recursion_dynamic/fibonacci/fibonacci_challenge.ipynb b/recursion_dynamic/fibonacci/fibonacci_challenge.ipynb index ae55619..a61eae0 100644 --- a/recursion_dynamic/fibonacci/fibonacci_challenge.ipynb +++ b/recursion_dynamic/fibonacci/fibonacci_challenge.ipynb @@ -88,6 +88,7 @@ "num_items = 10\n", "cache = [None] * (num_items + 1)\n", "\n", + "\n", "def fib_dynamic(n):\n", " # TODO: Implement me\n", " pass" @@ -130,7 +131,7 @@ "\n", "\n", "class TestFib(object):\n", - " \n", + "\n", " def test_fib(self, func):\n", " result = []\n", " for i in range(num_items):\n", @@ -139,12 +140,14 @@ " assert_equal(result, fib_seq)\n", " print('Success: test_fib')\n", "\n", + "\n", "def main():\n", " test = TestFib()\n", " test.test_fib(fib_recursive)\n", " test.test_fib(fib_dynamic)\n", " test.test_fib(fib_iterative)\n", "\n", + "\n", "if __name__ == '__main__':\n", " main()" ] diff --git a/recursion_dynamic/fibonacci/fibonacci_solution.ipynb b/recursion_dynamic/fibonacci/fibonacci_solution.ipynb index 3a3cfb8..c95948c 100644 --- a/recursion_dynamic/fibonacci/fibonacci_solution.ipynb +++ b/recursion_dynamic/fibonacci/fibonacci_solution.ipynb @@ -96,6 +96,7 @@ "num_items = 10\n", "cache = [None] * (num_items + 1)\n", "\n", + "\n", "def fib_dynamic(n):\n", " if n == 0 or n == 1:\n", " return n\n", @@ -114,7 +115,7 @@ "outputs": [], "source": [ "def fib_iterative(n):\n", - " a = 0 \n", + " a = 0\n", " b = 1\n", " for _ in range(n):\n", " a, b = b, a + b\n", @@ -150,7 +151,7 @@ "\n", "\n", "class TestFib(object):\n", - " \n", + "\n", " def test_fib(self, func):\n", " result = []\n", " for i in range(num_items):\n", @@ -159,12 +160,14 @@ " assert_equal(result, fib_seq)\n", " print('Success: test_fib')\n", "\n", + "\n", "def main():\n", " test = TestFib()\n", " test.test_fib(fib_recursive)\n", " test.test_fib(fib_dynamic)\n", " test.test_fib(fib_iterative)\n", "\n", + "\n", "if __name__ == '__main__':\n", " main()" ] diff --git a/recursion_dynamic/fibonacci/test_fibonacci.py b/recursion_dynamic/fibonacci/test_fibonacci.py index ced1b0a..b28f0a0 100644 --- a/recursion_dynamic/fibonacci/test_fibonacci.py +++ b/recursion_dynamic/fibonacci/test_fibonacci.py @@ -11,11 +11,13 @@ class TestFib(object): assert_equal(result, fib_seq) print('Success: test_fib') + def main(): test = TestFib() test.test_fib(fib_recursive) test.test_fib(fib_dynamic) test.test_fib(fib_iterative) + if __name__ == '__main__': main() \ No newline at end of file