mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-06 17:38:02 +00:00
Cleaned up cell execution numbers, minor PEP8 line break tweak.
This commit is contained in:
@@ -100,13 +100,7 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false
|
"collapsed": false
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name":"stdout",
|
|
||||||
"text":[],
|
|
||||||
"output_type": "stream"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"# %load test_coin_change_ways.py\n",
|
"# %load test_coin_change_ways.py\n",
|
||||||
"from nose.tools import assert_equal\n",
|
"from nose.tools import assert_equal\n",
|
||||||
@@ -117,7 +111,8 @@
|
|||||||
" def test_coin_change_ways(self,solution):\n",
|
" def test_coin_change_ways(self,solution):\n",
|
||||||
" assert_equal(solution(0, [1, 2]), 0)\n",
|
" assert_equal(solution(0, [1, 2]), 0)\n",
|
||||||
" assert_equal(solution(100, [1, 2, 3]), 884)\n",
|
" assert_equal(solution(100, [1, 2, 3]), 884)\n",
|
||||||
" assert_equal(solution(1000, range(1, 101)), 15658181104580771094597751280645)\n",
|
" assert_equal(solution(1000, range(1, 101)), \n",
|
||||||
|
" 15658181104580771094597751280645)\n",
|
||||||
" print('Success: test_coin_change_ways')\n",
|
" print('Success: test_coin_change_ways')\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -156,7 +151,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython2",
|
"pygments_lexer": "ipython2",
|
||||||
"version": "2.7.6"
|
"version": "2.7.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
@@ -73,12 +73,12 @@
|
|||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"def change_ways(n, coins):\n",
|
"def change_ways(n, coins):\n",
|
||||||
" arr = [1] + [0] * n\n",
|
" arr = [1] + [0] * n\n",
|
||||||
" for coin in coins:\n",
|
" for coin in coins:\n",
|
||||||
" for i in range(coin, n + 1):\n",
|
" for i in range(coin, n + 1):\n",
|
||||||
" arr[i] += arr[i - coin]\n",
|
" arr[i] += arr[i - coin]\n",
|
||||||
" return 0 if n == 0 else arr[n]"
|
" return 0 if n == 0 else arr[n]"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 5,
|
"execution_count": 2,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false
|
"collapsed": false
|
||||||
},
|
},
|
||||||
@@ -114,7 +114,8 @@
|
|||||||
" def test_coin_change_ways(self,solution):\n",
|
" def test_coin_change_ways(self,solution):\n",
|
||||||
" assert_equal(solution(0, [1, 2]), 0)\n",
|
" assert_equal(solution(0, [1, 2]), 0)\n",
|
||||||
" assert_equal(solution(100, [1, 2, 3]), 884)\n",
|
" assert_equal(solution(100, [1, 2, 3]), 884)\n",
|
||||||
" assert_equal(solution(1000, range(1, 101)), 15658181104580771094597751280645)\n",
|
" assert_equal(solution(1000, range(1, 101)), \n",
|
||||||
|
" 15658181104580771094597751280645)\n",
|
||||||
" print('Success: test_coin_change_ways')\n",
|
" print('Success: test_coin_change_ways')\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -129,7 +130,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 4,
|
"execution_count": 3,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false
|
"collapsed": false
|
||||||
},
|
},
|
||||||
@@ -145,15 +146,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"%run -i test_coin_change_ways.py"
|
"%run -i test_coin_change_ways.py"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {
|
|
||||||
"collapsed": true
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -172,7 +164,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython2",
|
"pygments_lexer": "ipython2",
|
||||||
"version": "2.7.6"
|
"version": "2.7.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
Reference in New Issue
Block a user