mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 10:58:02 +00:00
Move Fibonacci challenge code to a class (#140)
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user