Move Fibonacci challenge code to a class (#140)

This commit is contained in:
Donne Martin
2017-01-22 12:06:58 -05:00
committed by GitHub
parent f71936199b
commit 91b3efc3e4
3 changed files with 53 additions and 83 deletions

View File

@@ -76,39 +76,23 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": true
},
"outputs": [],
"source": [
"def fib_recursive(n):\n",
" # TODO: Implement me\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def fib_iterative(n):\n",
" # TODO: Implement me\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def fib_dynamic(n):\n",
" # TODO: Implement me\n",
" pass"
"class Math(object):\n",
"\n",
" def fib_iterative(self, n):\n",
" # TODO: Implement me\n",
" pass\n",
"\n",
" def fib_recursive(self, n):\n",
" # TODO: Implement me\n",
" pass\n",
"\n",
" def fib_dynamic(self, n):\n",
" # TODO: Implement me\n",
" pass"
]
},
{
@@ -147,9 +131,10 @@
"\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",
" math = Math()\n",
" test.test_fib(math.fib_recursive)\n",
" test.test_fib(math.fib_dynamic)\n",
" test.test_fib(math.fib_iterative)\n",
"\n",
"\n",
"if __name__ == '__main__':\n",