Renamed coinchange to coin_change.

This commit is contained in:
Donne Martin 2015-08-09 07:25:08 -04:00
parent 9ed7c05318
commit f74d40926c
4 changed files with 17 additions and 17 deletions

View File

@ -232,7 +232,7 @@ Challenges, solutions, and unit tests are presented in the form of **IPython/Jup
|--------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------| |--------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|
| Implement fibonacci recursively, dynamically, and iteratively | [Challenge](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/fibonacci/fibonacci_challenge.ipynb)│[Solution](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/fibonacci/fibonacci_solution.ipynb) | | Implement fibonacci recursively, dynamically, and iteratively | [Challenge](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/fibonacci/fibonacci_challenge.ipynb)│[Solution](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/fibonacci/fibonacci_solution.ipynb) |
| Implement the Towers of Hanoi with 3 towers and N disks | [Challenge](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/hanoi/hanoi_challenge.ipynb)│[Solution](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/hanoi/hanoi_solution.ipynb) | | Implement the Towers of Hanoi with 3 towers and N disks | [Challenge](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/hanoi/hanoi_challenge.ipynb)│[Solution](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/hanoi/hanoi_solution.ipynb) |
| Find the number of ways to represent n cents given an array of coins | [Challenge](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/coinchange_ways/coinchange_ways_challenge.ipynb)│[Solution](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/coinchange_ways/coinchange_ways_solution.ipynb) | | Find the number of ways to represent n cents given an array of coins | [Challenge](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/coin_change_ways/coin_change_ways_challenge.ipynb)│[Solution](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/coin_change_ways/coin_change_ways_solution.ipynb) |
| Implement factorial recursively, dynamically, and iteratively | [Contribute](https://github.com/donnemartin/interactive-coding-challenges/blob/master/CONTRIBUTING.md)│[Contribute](https://github.com/donnemartin/interactive-coding-challenges/blob/master/CONTRIBUTING.md) | | Implement factorial recursively, dynamically, and iteratively | [Contribute](https://github.com/donnemartin/interactive-coding-challenges/blob/master/CONTRIBUTING.md)│[Contribute](https://github.com/donnemartin/interactive-coding-challenges/blob/master/CONTRIBUTING.md) |
| Perform a binary search on a sorted array of integers | [Contribute](https://github.com/donnemartin/interactive-coding-challenges/blob/master/CONTRIBUTING.md)│[Contribute](https://github.com/donnemartin/interactive-coding-challenges/blob/master/CONTRIBUTING.md) | | Perform a binary search on a sorted array of integers | [Contribute](https://github.com/donnemartin/interactive-coding-challenges/blob/master/CONTRIBUTING.md)│[Contribute](https://github.com/donnemartin/interactive-coding-challenges/blob/master/CONTRIBUTING.md) |
| Print all subsets of a set | [Contribute](https://github.com/donnemartin/interactive-coding-challenges/blob/master/CONTRIBUTING.md)│[Contribute](https://github.com/donnemartin/interactive-coding-challenges/blob/master/CONTRIBUTING.md) | | Print all subsets of a set | [Contribute](https://github.com/donnemartin/interactive-coding-challenges/blob/master/CONTRIBUTING.md)│[Contribute](https://github.com/donnemartin/interactive-coding-challenges/blob/master/CONTRIBUTING.md) |

View File

@ -60,7 +60,7 @@
"source": [ "source": [
"## Algorithm\n", "## Algorithm\n",
"\n", "\n",
"Refer to the [Solution Notebook](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/coinchange_ways/coinchange_ways_solution.ipynb). If you are stuck and need a hint, the solution notebook's algorithm discussion might be a good place to start." "Refer to the [Solution Notebook](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/coin_change_ways/coin_change_ways_solution.ipynb). If you are stuck and need a hint, the solution notebook's algorithm discussion might be a good place to start."
] ]
}, },
{ {
@ -108,22 +108,22 @@
} }
], ],
"source": [ "source": [
"# %load test_coinchange_ways.py\n", "# %load test_coin_change_ways.py\n",
"from nose.tools import assert_equal\n", "from nose.tools import assert_equal\n",
"\n", "\n",
"\n", "\n",
"class Challenge(object):\n", "class Challenge(object):\n",
"\n", "\n",
" def test_coinchange_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)), 15658181104580771094597751280645)\n",
" print('Success: test_coinchange_ways')\n", " print('Success: test_coin_change_ways')\n",
"\n", "\n",
"\n", "\n",
"def main():\n", "def main():\n",
" test = Challenge()\n", " test = Challenge()\n",
" test.test_coinchange_ways(change_ways)\n", " test.test_coin_change_ways(change_ways)\n",
"\n", "\n",
"\n", "\n",
"if __name__ == '__main__':\n", "if __name__ == '__main__':\n",
@ -136,7 +136,7 @@
"source": [ "source": [
"## Solution Notebook\n", "## Solution Notebook\n",
"\n", "\n",
"Review the [Solution Notebook](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/coinchange_ways/coinchange_ways_solution.ipynb) for a discussion on algorithms and code solutions." "Review the [Solution Notebook](http://nbviewer.ipython.org/github/donnemartin/interactive-coding-challenges/blob/master/recursion_dynamic/coin_change_ways/coin_change_ways_solution.ipynb) for a discussion on algorithms and code solutions."
] ]
} }
], ],

View File

@ -100,27 +100,27 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Overwriting test_coinchange_ways.py\n" "Overwriting test_coin_change_ways.py\n"
] ]
} }
], ],
"source": [ "source": [
"%%writefile test_coinchange_ways.py\n", "%%writefile test_coin_change_ways.py\n",
"from nose.tools import assert_equal\n", "from nose.tools import assert_equal\n",
"\n", "\n",
"\n", "\n",
"class Challenge(object):\n", "class Challenge(object):\n",
"\n", "\n",
" def test_coinchange_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)), 15658181104580771094597751280645)\n",
" print('Success: test_coinchange_ways')\n", " print('Success: test_coin_change_ways')\n",
"\n", "\n",
"\n", "\n",
"def main():\n", "def main():\n",
" test = Challenge()\n", " test = Challenge()\n",
" test.test_coinchange_ways(change_ways)\n", " test.test_coin_change_ways(change_ways)\n",
"\n", "\n",
"\n", "\n",
"if __name__ == '__main__':\n", "if __name__ == '__main__':\n",
@ -138,12 +138,12 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Success: test_coinchange_ways\n" "Success: test_coin_change_ways\n"
] ]
} }
], ],
"source": [ "source": [
"%run -i test_coinchange_ways.py" "%run -i test_coin_change_ways.py"
] ]
}, },
{ {

View File

@ -3,16 +3,16 @@ from nose.tools import assert_equal
class Challenge(object): class Challenge(object):
def test_coinchange_ways(self,solution): def test_coin_change_ways(self,solution):
assert_equal(solution(0, [1, 2]), 0) assert_equal(solution(0, [1, 2]), 0)
assert_equal(solution(100, [1, 2, 3]), 884) assert_equal(solution(100, [1, 2, 3]), 884)
assert_equal(solution(1000, range(1, 101)), 15658181104580771094597751280645) assert_equal(solution(1000, range(1, 101)), 15658181104580771094597751280645)
print('Success: test_coinchange_ways') print('Success: test_coin_change_ways')
def main(): def main():
test = Challenge() test = Challenge()
test.test_coinchange_ways(change_ways) test.test_coin_change_ways(change_ways)
if __name__ == '__main__': if __name__ == '__main__':