From 76cb6507fccaa9f8aa8c608ce9a718bbe5e82628 Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Mon, 13 Jul 2020 21:26:50 -0400 Subject: [PATCH] #273: Remove nose dependency for recursion_dynamic/ (#280) --- .../coin_change/coin_change_challenge.ipynb | 22 ++++----- .../coin_change/coin_change_solution.ipynb | 26 ++++------ .../coin_change/test_coin_change.py | 12 ++--- .../coin_change_min_challenge.ipynb | 26 +++++----- .../coin_change_min_solution.ipynb | 30 +++++------- .../coin_change_min/test_coin_change_min.py | 16 +++---- .../coin_change_ways_challenge.ipynb | 22 ++++----- .../coin_change_ways_solution.ipynb | 26 ++++------ .../coin_change_ways/test_coin_change_ways.py | 13 ++--- .../fibonacci/fibonacci_challenge.ipynb | 14 +++--- .../fibonacci/fibonacci_solution.ipynb | 22 ++++----- recursion_dynamic/fibonacci/test_fibonacci.py | 8 ++-- .../grid_path/grid_path_challenge.ipynb | 24 ++++------ .../grid_path/grid_path_solution.ipynb | 28 +++++------ recursion_dynamic/grid_path/test_grid_path.py | 14 +++--- recursion_dynamic/hanoi/hanoi_challenge.ipynb | 28 +++++------ recursion_dynamic/hanoi/hanoi_solution.ipynb | 32 +++++-------- recursion_dynamic/hanoi/test_hanoi.py | 14 +++--- .../knapsack_01/knapsack_challenge.ipynb | 22 ++++----- .../knapsack_01/knapsack_solution.ipynb | 48 +++++++------------ .../knapsack_01/test_knapsack.py | 22 ++++----- .../knapsack_unbounded_challenge.ipynb | 22 ++++----- .../knapsack_unbounded_solution.ipynb | 30 +++++------- .../test_knapsack_unbounded.py | 12 ++--- .../longest_common_subseq_challenge.ipynb | 22 ++++----- .../longest_common_subseq_solution.ipynb | 26 ++++------ .../test_longest_common_subseq.py | 10 ++-- .../longest_inc_subseq_challenge.ipynb | 22 ++++----- .../longest_inc_subseq_solution.ipynb | 26 ++++------ .../test_longest_increasing_subseq.py | 12 ++--- .../longest_substr_challenge.ipynb | 24 ++++------ .../longest_substr_solution.ipynb | 28 +++++------ .../test_longest_substr.py | 14 +++--- .../longest_common_substr_challenge.ipynb | 22 ++++----- .../longest_common_substr_solution.ipynb | 26 ++++------ .../test_longest_common_substr.py | 12 ++--- .../magic_index/magic_index_challenge.ipynb | 26 +++++----- .../magic_index/magic_index_solution.ipynb | 30 +++++------- .../magic_index/test_find_magic_index.py | 16 +++---- .../matrix_mult/find_min_cost_challenge.ipynb | 22 ++++----- .../matrix_mult/find_min_cost_solution.ipynb | 30 +++++------- .../matrix_mult/test_find_min_cost.py | 12 ++--- .../max_profit_k/max_profit_challenge.ipynb | 38 +++++++-------- .../max_profit_k/max_profit_solution.ipynb | 46 +++++++----------- .../max_profit_k/test_max_profit.py | 28 +++++------ .../n_pairs_parentheses_challenge.ipynb | 24 +++++----- .../n_pairs_parentheses_solution.ipynb | 32 +++++-------- .../test_n_pairs_parentheses.py | 18 +++---- .../permutations/permutations_challenge.ipynb | 22 ++++----- .../permutations/permutations_solution.ipynb | 26 ++++------ .../permutations/test_permutations.py | 12 ++--- .../power_set/power_set_challenge.ipynb | 20 ++++---- .../power_set/power_set_solution.ipynb | 22 ++++----- recursion_dynamic/power_set/test_power_set.py | 8 ++-- recursion_dynamic/steps/steps_challenge.ipynb | 32 ++++++------- recursion_dynamic/steps/steps_solution.ipynb | 36 ++++++-------- recursion_dynamic/steps/test_steps.py | 22 ++++----- 57 files changed, 548 insertions(+), 751 deletions(-) diff --git a/recursion_dynamic/coin_change/coin_change_challenge.ipynb b/recursion_dynamic/coin_change/coin_change_challenge.ipynb index c552f50..bbb6945 100644 --- a/recursion_dynamic/coin_change/coin_change_challenge.ipynb +++ b/recursion_dynamic/coin_change/coin_change_challenge.ipynb @@ -76,9 +76,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class CoinChanger(object):\n", @@ -102,22 +100,20 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_coin_change.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class Challenge(object):\n", + "class Challenge(unittest.TestCase):\n", "\n", " def test_coin_change(self):\n", " coin_changer = CoinChanger()\n", - " assert_equal(coin_changer.make_change([1, 2], 0), 0)\n", - " assert_equal(coin_changer.make_change([1, 2, 3], 5), 5)\n", - " assert_equal(coin_changer.make_change([1, 5, 25, 50], 10), 3)\n", + " self.assertEqual(coin_changer.make_change([1, 2], 0), 0)\n", + " self.assertEqual(coin_changer.make_change([1, 2, 3], 5), 5)\n", + " self.assertEqual(coin_changer.make_change([1, 5, 25, 50], 10), 3)\n", " print('Success: test_coin_change')\n", "\n", "\n", @@ -156,9 +152,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/coin_change/coin_change_solution.ipynb b/recursion_dynamic/coin_change/coin_change_solution.ipynb index 44da41f..fc6c47e 100644 --- a/recursion_dynamic/coin_change/coin_change_solution.ipynb +++ b/recursion_dynamic/coin_change/coin_change_solution.ipynb @@ -108,9 +108,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "class CoinChanger(object):\n", @@ -150,9 +148,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -164,16 +160,16 @@ ], "source": [ "%%writefile test_coin_change.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class Challenge(object):\n", + "class Challenge(unittest.TestCase):\n", "\n", " def test_coin_change(self):\n", " coin_changer = CoinChanger()\n", - " assert_equal(coin_changer.make_change([1, 2], 0), 0)\n", - " assert_equal(coin_changer.make_change([1, 2, 3], 5), 5)\n", - " assert_equal(coin_changer.make_change([1, 5, 25, 50], 10), 3)\n", + " self.assertEqual(coin_changer.make_change([1, 2], 0), 0)\n", + " self.assertEqual(coin_changer.make_change([1, 2, 3], 5), 5)\n", + " self.assertEqual(coin_changer.make_change([1, 5, 25, 50], 10), 3)\n", " print('Success: test_coin_change')\n", "\n", "\n", @@ -189,9 +185,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -222,9 +216,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/coin_change/test_coin_change.py b/recursion_dynamic/coin_change/test_coin_change.py index 8d8efb2..1c01f16 100644 --- a/recursion_dynamic/coin_change/test_coin_change.py +++ b/recursion_dynamic/coin_change/test_coin_change.py @@ -1,13 +1,13 @@ -from nose.tools import assert_equal +import unittest -class Challenge(object): +class Challenge(unittest.TestCase): def test_coin_change(self): coin_changer = CoinChanger() - assert_equal(coin_changer.make_change([1, 2], 0), 0) - assert_equal(coin_changer.make_change([1, 2, 3], 5), 5) - assert_equal(coin_changer.make_change([1, 5, 25, 50], 10), 3) + self.assertEqual(coin_changer.make_change([1, 2], 0), 0) + self.assertEqual(coin_changer.make_change([1, 2, 3], 5), 5) + self.assertEqual(coin_changer.make_change([1, 5, 25, 50], 10), 3) print('Success: test_coin_change') @@ -17,4 +17,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/coin_change_min/coin_change_min_challenge.ipynb b/recursion_dynamic/coin_change_min/coin_change_min_challenge.ipynb index 5acd777..51c5cb7 100644 --- a/recursion_dynamic/coin_change_min/coin_change_min_challenge.ipynb +++ b/recursion_dynamic/coin_change_min/coin_change_min_challenge.ipynb @@ -76,9 +76,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class CoinChanger(object):\n", @@ -105,24 +103,22 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_coin_change_min.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestCoinChange(object):\n", + "class TestCoinChange(unittest.TestCase):\n", "\n", " def test_coin_change(self):\n", " coin_changer = CoinChanger()\n", - " assert_raises(TypeError, coin_changer.make_change, None, None)\n", - " assert_equal(coin_changer.make_change([], 0), 0)\n", - " assert_equal(coin_changer.make_change([1, 2, 3], 5), 2)\n", - " assert_equal(coin_changer.make_change([3, 2, 1], 5), 2)\n", - " assert_equal(coin_changer.make_change([3, 2, 1], 8), 3)\n", + " self.assertRaises(TypeError, coin_changer.make_change, None, None)\n", + " self.assertEqual(coin_changer.make_change([], 0), 0)\n", + " self.assertEqual(coin_changer.make_change([1, 2, 3], 5), 2)\n", + " self.assertEqual(coin_changer.make_change([3, 2, 1], 5), 2)\n", + " self.assertEqual(coin_changer.make_change([3, 2, 1], 8), 3)\n", " print('Success: test_coin_change')\n", "\n", "\n", @@ -161,9 +157,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/coin_change_min/coin_change_min_solution.ipynb b/recursion_dynamic/coin_change_min/coin_change_min_solution.ipynb index d1960fb..7d3af61 100644 --- a/recursion_dynamic/coin_change_min/coin_change_min_solution.ipynb +++ b/recursion_dynamic/coin_change_min/coin_change_min_solution.ipynb @@ -116,9 +116,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "import sys\n", @@ -160,9 +158,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -174,18 +170,18 @@ ], "source": [ "%%writefile test_coin_change_min.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestCoinChange(object):\n", + "class TestCoinChange(unittest.TestCase):\n", "\n", " def test_coin_change(self):\n", " coin_changer = CoinChanger()\n", - " assert_raises(TypeError, coin_changer.make_change, None, None)\n", - " assert_equal(coin_changer.make_change([], 0), 0)\n", - " assert_equal(coin_changer.make_change([1, 2, 3], 5), 2)\n", - " assert_equal(coin_changer.make_change([3, 2, 1], 5), 2)\n", - " assert_equal(coin_changer.make_change([3, 2, 1], 8), 3)\n", + " self.assertRaises(TypeError, coin_changer.make_change, None, None)\n", + " self.assertEqual(coin_changer.make_change([], 0), 0)\n", + " self.assertEqual(coin_changer.make_change([1, 2, 3], 5), 2)\n", + " self.assertEqual(coin_changer.make_change([3, 2, 1], 5), 2)\n", + " self.assertEqual(coin_changer.make_change([3, 2, 1], 8), 3)\n", " print('Success: test_coin_change')\n", "\n", "\n", @@ -201,9 +197,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -234,9 +228,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/coin_change_min/test_coin_change_min.py b/recursion_dynamic/coin_change_min/test_coin_change_min.py index 2440185..de7c3da 100644 --- a/recursion_dynamic/coin_change_min/test_coin_change_min.py +++ b/recursion_dynamic/coin_change_min/test_coin_change_min.py @@ -1,15 +1,15 @@ -from nose.tools import assert_equal, assert_raises +import unittest -class TestCoinChange(object): +class TestCoinChange(unittest.TestCase): def test_coin_change(self): coin_changer = CoinChanger() - assert_raises(TypeError, coin_changer.make_change, None, None) - assert_equal(coin_changer.make_change([], 0), 0) - assert_equal(coin_changer.make_change([1, 2, 3], 5), 2) - assert_equal(coin_changer.make_change([3, 2, 1], 5), 2) - assert_equal(coin_changer.make_change([3, 2, 1], 8), 3) + self.assertRaises(TypeError, coin_changer.make_change, None, None) + self.assertEqual(coin_changer.make_change([], 0), 0) + self.assertEqual(coin_changer.make_change([1, 2, 3], 5), 2) + self.assertEqual(coin_changer.make_change([3, 2, 1], 5), 2) + self.assertEqual(coin_changer.make_change([3, 2, 1], 8), 3) print('Success: test_coin_change') @@ -19,4 +19,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/coin_change_ways/coin_change_ways_challenge.ipynb b/recursion_dynamic/coin_change_ways/coin_change_ways_challenge.ipynb index 8d62bdf..59ebea2 100644 --- a/recursion_dynamic/coin_change_ways/coin_change_ways_challenge.ipynb +++ b/recursion_dynamic/coin_change_ways/coin_change_ways_challenge.ipynb @@ -73,9 +73,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "def change_ways(n, coins):\n", @@ -97,21 +95,19 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_coin_change_ways.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class Challenge(object):\n", + "class Challenge(unittest.TestCase):\n", "\n", " def test_coin_change_ways(self,solution):\n", - " assert_equal(solution(0, [1, 2]), 0)\n", - " assert_equal(solution(100, [1, 2, 3]), 884)\n", - " assert_equal(solution(1000, range(1, 101)), \n", + " self.assertEqual(solution(0, [1, 2]), 0)\n", + " self.assertEqual(solution(100, [1, 2, 3]), 884)\n", + " self.assertEqual(solution(1000, range(1, 101)), \n", " 15658181104580771094597751280645)\n", " print('Success: test_coin_change_ways')\n", "\n", @@ -151,9 +147,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/coin_change_ways/coin_change_ways_solution.ipynb b/recursion_dynamic/coin_change_ways/coin_change_ways_solution.ipynb index 72bffcf..391d731 100644 --- a/recursion_dynamic/coin_change_ways/coin_change_ways_solution.ipynb +++ b/recursion_dynamic/coin_change_ways/coin_change_ways_solution.ipynb @@ -68,9 +68,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "def change_ways(n, coins):\n", @@ -92,9 +90,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -106,15 +102,15 @@ ], "source": [ "%%writefile test_coin_change_ways.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class Challenge(object):\n", + "class Challenge(unittest.TestCase):\n", "\n", " def test_coin_change_ways(self,solution):\n", - " assert_equal(solution(0, [1, 2]), 0)\n", - " assert_equal(solution(100, [1, 2, 3]), 884)\n", - " assert_equal(solution(1000, range(1, 101)), \n", + " self.assertEqual(solution(0, [1, 2]), 0)\n", + " self.assertEqual(solution(100, [1, 2, 3]), 884)\n", + " self.assertEqual(solution(1000, range(1, 101)), \n", " 15658181104580771094597751280645)\n", " print('Success: test_coin_change_ways')\n", "\n", @@ -131,9 +127,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -164,9 +158,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/coin_change_ways/test_coin_change_ways.py b/recursion_dynamic/coin_change_ways/test_coin_change_ways.py index 01e56da..0dcd5e2 100644 --- a/recursion_dynamic/coin_change_ways/test_coin_change_ways.py +++ b/recursion_dynamic/coin_change_ways/test_coin_change_ways.py @@ -1,12 +1,13 @@ -from nose.tools import assert_equal +import unittest -class Challenge(object): +class Challenge(unittest.TestCase): def test_coin_change_ways(self,solution): - assert_equal(solution(0, [1, 2]), 0) - assert_equal(solution(100, [1, 2, 3]), 884) - assert_equal(solution(1000, range(1, 101)), 15658181104580771094597751280645) + self.assertEqual(solution(0, [1, 2]), 0) + self.assertEqual(solution(100, [1, 2, 3]), 884) + self.assertEqual(solution(1000, range(1, 101)), + 15658181104580771094597751280645) print('Success: test_coin_change_ways') @@ -16,4 +17,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/fibonacci/fibonacci_challenge.ipynb b/recursion_dynamic/fibonacci/fibonacci_challenge.ipynb index 6907fd6..debade9 100644 --- a/recursion_dynamic/fibonacci/fibonacci_challenge.ipynb +++ b/recursion_dynamic/fibonacci/fibonacci_challenge.ipynb @@ -109,23 +109,21 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_fibonacci.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class TestFib(object):\n", + "class TestFib(unittest.TestCase):\n", "\n", " def test_fib(self, func):\n", " result = []\n", " expected = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]\n", " for i in range(len(expected)):\n", " result.append(func(i))\n", - " assert_equal(result, expected)\n", + " self.assertEqual(result, expected)\n", " print('Success: test_fib')\n", "\n", "\n", @@ -167,9 +165,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/fibonacci/fibonacci_solution.ipynb b/recursion_dynamic/fibonacci/fibonacci_solution.ipynb index f492e3c..7d942fb 100644 --- a/recursion_dynamic/fibonacci/fibonacci_solution.ipynb +++ b/recursion_dynamic/fibonacci/fibonacci_solution.ipynb @@ -81,9 +81,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "class Math(object):\n", @@ -125,9 +123,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -139,17 +135,17 @@ ], "source": [ "%%writefile test_fibonacci.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class TestFib(object):\n", + "class TestFib(unittest.TestCase):\n", "\n", " def test_fib(self, func):\n", " result = []\n", " expected = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]\n", " for i in range(len(expected)):\n", " result.append(func(i))\n", - " assert_equal(result, expected)\n", + " self.assertEqual(result, expected)\n", " print('Success: test_fib')\n", "\n", "\n", @@ -168,9 +164,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -203,9 +197,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/fibonacci/test_fibonacci.py b/recursion_dynamic/fibonacci/test_fibonacci.py index fed4907..bcb06ed 100644 --- a/recursion_dynamic/fibonacci/test_fibonacci.py +++ b/recursion_dynamic/fibonacci/test_fibonacci.py @@ -1,14 +1,14 @@ -from nose.tools import assert_equal +import unittest -class TestFib(object): +class TestFib(unittest.TestCase): def test_fib(self, func): result = [] expected = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] for i in range(len(expected)): result.append(func(i)) - assert_equal(result, expected) + self.assertEqual(result, expected) print('Success: test_fib') @@ -21,4 +21,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/grid_path/grid_path_challenge.ipynb b/recursion_dynamic/grid_path/grid_path_challenge.ipynb index d9139a5..da9a0a2 100644 --- a/recursion_dynamic/grid_path/grid_path_challenge.ipynb +++ b/recursion_dynamic/grid_path/grid_path_challenge.ipynb @@ -102,9 +102,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Grid(object):\n", @@ -131,21 +129,19 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_grid_path.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class TestGridPath(object):\n", + "class TestGridPath(unittest.TestCase):\n", "\n", " def test_grid_path(self):\n", " grid = Grid()\n", - " assert_equal(grid.find_path(None), None)\n", - " assert_equal(grid.find_path([[]]), None)\n", + " self.assertEqual(grid.find_path(None), None)\n", + " self.assertEqual(grid.find_path([[]]), None)\n", " max_rows = 8\n", " max_cols = 4\n", " matrix = [[1] * max_cols for _ in range(max_rows)]\n", @@ -162,10 +158,10 @@ " (2, 1), (3, 1), (4, 1),\n", " (5, 1), (5, 2), (6, 2), \n", " (7, 2), (7, 3)]\n", - " assert_equal(result, expected)\n", + " self.assertEqual(result, expected)\n", " matrix[7][2] = 0\n", " result = grid.find_path(matrix)\n", - " assert_equal(result, None)\n", + " self.assertEqual(result, None)\n", " print('Success: test_grid_path')\n", "\n", "\n", @@ -204,9 +200,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/grid_path/grid_path_solution.ipynb b/recursion_dynamic/grid_path/grid_path_solution.ipynb index 18fc1f8..514837d 100644 --- a/recursion_dynamic/grid_path/grid_path_solution.ipynb +++ b/recursion_dynamic/grid_path/grid_path_solution.ipynb @@ -135,9 +135,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Grid(object):\n", @@ -177,9 +175,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -191,15 +187,15 @@ ], "source": [ "%%writefile test_grid_path.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class TestGridPath(object):\n", + "class TestGridPath(unittest.TestCase):\n", "\n", " def test_grid_path(self):\n", " grid = Grid()\n", - " assert_equal(grid.find_path(None), None)\n", - " assert_equal(grid.find_path([[]]), None)\n", + " self.assertEqual(grid.find_path(None), None)\n", + " self.assertEqual(grid.find_path([[]]), None)\n", " max_rows = 8\n", " max_cols = 4\n", " matrix = [[1] * max_cols for _ in range(max_rows)]\n", @@ -216,10 +212,10 @@ " (2, 1), (3, 1), (4, 1),\n", " (5, 1), (5, 2), (6, 2), \n", " (7, 2), (7, 3)]\n", - " assert_equal(result, expected)\n", + " self.assertEqual(result, expected)\n", " matrix[7][2] = 0\n", " result = grid.find_path(matrix)\n", - " assert_equal(result, None)\n", + " self.assertEqual(result, None)\n", " print('Success: test_grid_path')\n", "\n", "\n", @@ -235,9 +231,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -268,9 +262,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/grid_path/test_grid_path.py b/recursion_dynamic/grid_path/test_grid_path.py index 9249cda..f978710 100644 --- a/recursion_dynamic/grid_path/test_grid_path.py +++ b/recursion_dynamic/grid_path/test_grid_path.py @@ -1,12 +1,12 @@ -from nose.tools import assert_equal +import unittest -class TestGridPath(object): +class TestGridPath(unittest.TestCase): def test_grid_path(self): grid = Grid() - assert_equal(grid.find_path(None), None) - assert_equal(grid.find_path([[]]), None) + self.assertEqual(grid.find_path(None), None) + self.assertEqual(grid.find_path([[]]), None) max_rows = 8 max_cols = 4 matrix = [[1] * max_cols for _ in range(max_rows)] @@ -23,10 +23,10 @@ class TestGridPath(object): (2, 1), (3, 1), (4, 1), (5, 1), (5, 2), (6, 2), (7, 2), (7, 3)] - assert_equal(result, expected) + self.assertEqual(result, expected) matrix[7][2] = 0 result = grid.find_path(matrix) - assert_equal(result, None) + self.assertEqual(result, None) print('Success: test_grid_path') @@ -36,4 +36,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/hanoi/hanoi_challenge.ipynb b/recursion_dynamic/hanoi/hanoi_challenge.ipynb index 624f168..bc19e7a 100644 --- a/recursion_dynamic/hanoi/hanoi_challenge.ipynb +++ b/recursion_dynamic/hanoi/hanoi_challenge.ipynb @@ -73,9 +73,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "%run ../../stacks_queues/stack/stack.py\n", @@ -85,9 +83,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Hanoi(object):\n", @@ -111,16 +107,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_hanoi.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestHanoi(object):\n", + "class TestHanoi(unittest.TestCase):\n", "\n", " def test_hanoi(self):\n", " hanoi = Hanoi()\n", @@ -130,23 +124,23 @@ " dest = Stack()\n", "\n", " print('Test: None towers')\n", - " assert_raises(TypeError, hanoi.move_disks, num_disks, None, None, None)\n", + " self.assertRaises(TypeError, hanoi.move_disks, num_disks, None, None, None)\n", "\n", " print('Test: 0 disks')\n", " hanoi.move_disks(num_disks, src, dest, buff)\n", - " assert_equal(dest.pop(), None)\n", + " self.assertEqual(dest.pop(), None)\n", "\n", " print('Test: 1 disk')\n", " src.push(5)\n", " hanoi.move_disks(num_disks, src, dest, buff)\n", - " assert_equal(dest.pop(), 5)\n", + " self.assertEqual(dest.pop(), 5)\n", "\n", " print('Test: 2 or more disks')\n", " for disk_index in range(num_disks, -1, -1):\n", " src.push(disk_index)\n", " hanoi.move_disks(num_disks, src, dest, buff)\n", " for disk_index in range(0, num_disks):\n", - " assert_equal(dest.pop(), disk_index)\n", + " self.assertEqual(dest.pop(), disk_index)\n", "\n", " print('Success: test_hanoi')\n", "\n", @@ -186,9 +180,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/hanoi/hanoi_solution.ipynb b/recursion_dynamic/hanoi/hanoi_solution.ipynb index b5962f5..9f4676a 100644 --- a/recursion_dynamic/hanoi/hanoi_solution.ipynb +++ b/recursion_dynamic/hanoi/hanoi_solution.ipynb @@ -81,9 +81,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "%run ../../stacks_queues/stack/stack.py" @@ -92,9 +90,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Hanoi(object):\n", @@ -123,9 +119,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -137,10 +131,10 @@ ], "source": [ "%%writefile test_hanoi.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestHanoi(object):\n", + "class TestHanoi(unittest.TestCase):\n", "\n", " def test_hanoi(self):\n", " hanoi = Hanoi()\n", @@ -150,23 +144,23 @@ " dest = Stack()\n", "\n", " print('Test: None towers')\n", - " assert_raises(TypeError, hanoi.move_disks, num_disks, None, None, None)\n", + " self.assertRaises(TypeError, hanoi.move_disks, num_disks, None, None, None)\n", "\n", " print('Test: 0 disks')\n", " hanoi.move_disks(num_disks, src, dest, buff)\n", - " assert_equal(dest.pop(), None)\n", + " self.assertEqual(dest.pop(), None)\n", "\n", " print('Test: 1 disk')\n", " src.push(5)\n", " hanoi.move_disks(num_disks, src, dest, buff)\n", - " assert_equal(dest.pop(), 5)\n", + " self.assertEqual(dest.pop(), 5)\n", "\n", " print('Test: 2 or more disks')\n", " for disk_index in range(num_disks, -1, -1):\n", " src.push(disk_index)\n", " hanoi.move_disks(num_disks, src, dest, buff)\n", " for disk_index in range(0, num_disks):\n", - " assert_equal(dest.pop(), disk_index)\n", + " self.assertEqual(dest.pop(), disk_index)\n", "\n", " print('Success: test_hanoi')\n", "\n", @@ -183,9 +177,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -220,9 +212,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/hanoi/test_hanoi.py b/recursion_dynamic/hanoi/test_hanoi.py index f100254..04affeb 100644 --- a/recursion_dynamic/hanoi/test_hanoi.py +++ b/recursion_dynamic/hanoi/test_hanoi.py @@ -1,7 +1,7 @@ -from nose.tools import assert_equal, assert_raises +import unittest -class TestHanoi(object): +class TestHanoi(unittest.TestCase): def test_hanoi(self): hanoi = Hanoi() @@ -11,23 +11,23 @@ class TestHanoi(object): dest = Stack() print('Test: None towers') - assert_raises(TypeError, hanoi.move_disks, num_disks, None, None, None) + self.assertRaises(TypeError, hanoi.move_disks, num_disks, None, None, None) print('Test: 0 disks') hanoi.move_disks(num_disks, src, dest, buff) - assert_equal(dest.pop(), None) + self.assertEqual(dest.pop(), None) print('Test: 1 disk') src.push(5) hanoi.move_disks(num_disks, src, dest, buff) - assert_equal(dest.pop(), 5) + self.assertEqual(dest.pop(), 5) print('Test: 2 or more disks') for disk_index in range(num_disks, -1, -1): src.push(disk_index) hanoi.move_disks(num_disks, src, dest, buff) for disk_index in range(0, num_disks): - assert_equal(dest.pop(), disk_index) + self.assertEqual(dest.pop(), disk_index) print('Success: test_hanoi') @@ -38,4 +38,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/knapsack_01/knapsack_challenge.ipynb b/recursion_dynamic/knapsack_01/knapsack_challenge.ipynb index fee2d16..41d023f 100644 --- a/recursion_dynamic/knapsack_01/knapsack_challenge.ipynb +++ b/recursion_dynamic/knapsack_01/knapsack_challenge.ipynb @@ -145,15 +145,15 @@ "outputs": [], "source": [ "# %load test_knapsack.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestKnapsack(object):\n", + "class TestKnapsack(unittest.TestCase):\n", "\n", " def test_knapsack_bottom_up(self):\n", " knapsack = Knapsack()\n", - " assert_raises(TypeError, knapsack.fill_knapsack, None, None)\n", - " assert_equal(knapsack.fill_knapsack(0, 0), 0)\n", + " self.assertRaises(TypeError, knapsack.fill_knapsack, None, None)\n", + " self.assertEqual(knapsack.fill_knapsack(0, 0), 0)\n", " items = []\n", " items.append(Item(label='a', value=2, weight=2))\n", " items.append(Item(label='b', value=4, weight=2))\n", @@ -162,18 +162,18 @@ " total_weight = 8\n", " expected_value = 13\n", " results = knapsack.fill_knapsack(items, total_weight)\n", - " assert_equal(results[0].label, 'd')\n", - " assert_equal(results[1].label, 'b')\n", + " self.assertEqual(results[0].label, 'd')\n", + " self.assertEqual(results[1].label, 'b')\n", " total_value = 0\n", " for item in results:\n", " total_value += item.value\n", - " assert_equal(total_value, expected_value)\n", + " self.assertEqual(total_value, expected_value)\n", " print('Success: test_knapsack_bottom_up')\n", "\n", " def test_knapsack_top_down(self):\n", " knapsack = KnapsackTopDown()\n", - " assert_raises(TypeError, knapsack.fill_knapsack, None, None)\n", - " assert_equal(knapsack.fill_knapsack(0, 0), 0)\n", + " self.assertRaises(TypeError, knapsack.fill_knapsack, None, None)\n", + " self.assertEqual(knapsack.fill_knapsack(0, 0), 0)\n", " items = []\n", " items.append(Item(label='a', value=2, weight=2))\n", " items.append(Item(label='b', value=4, weight=2))\n", @@ -181,7 +181,7 @@ " items.append(Item(label='d', value=9, weight=5))\n", " total_weight = 8\n", " expected_value = 13\n", - " assert_equal(knapsack.fill_knapsack(items, total_weight), expected_value)\n", + " self.assertEqual(knapsack.fill_knapsack(items, total_weight), expected_value)\n", " print('Success: test_knapsack_top_down')\n", "\n", "def main():\n", @@ -220,7 +220,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.7.2" } }, "nbformat": 4, diff --git a/recursion_dynamic/knapsack_01/knapsack_solution.ipynb b/recursion_dynamic/knapsack_01/knapsack_solution.ipynb index aff4319..c759971 100644 --- a/recursion_dynamic/knapsack_01/knapsack_solution.ipynb +++ b/recursion_dynamic/knapsack_01/knapsack_solution.ipynb @@ -132,9 +132,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "class Item(object):\n", @@ -158,9 +156,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Knapsack(object):\n", @@ -208,9 +204,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class KnapsackTopDown(object):\n", @@ -255,9 +249,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Result(object):\n", @@ -328,9 +320,7 @@ { "cell_type": "code", "execution_count": 5, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -342,15 +332,15 @@ ], "source": [ "%%writefile test_knapsack.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestKnapsack(object):\n", + "class TestKnapsack(unittest.TestCase):\n", "\n", " def test_knapsack_bottom_up(self):\n", " knapsack = Knapsack()\n", - " assert_raises(TypeError, knapsack.fill_knapsack, None, None)\n", - " assert_equal(knapsack.fill_knapsack(0, 0), 0)\n", + " self.assertRaises(TypeError, knapsack.fill_knapsack, None, None)\n", + " self.assertEqual(knapsack.fill_knapsack(0, 0), 0)\n", " items = []\n", " items.append(Item(label='a', value=2, weight=2))\n", " items.append(Item(label='b', value=4, weight=2))\n", @@ -359,18 +349,18 @@ " total_weight = 8\n", " expected_value = 13\n", " results = knapsack.fill_knapsack(items, total_weight)\n", - " assert_equal(results[0].label, 'd')\n", - " assert_equal(results[1].label, 'b')\n", + " self.assertEqual(results[0].label, 'd')\n", + " self.assertEqual(results[1].label, 'b')\n", " total_value = 0\n", " for item in results:\n", " total_value += item.value\n", - " assert_equal(total_value, expected_value)\n", + " self.assertEqual(total_value, expected_value)\n", " print('Success: test_knapsack_bottom_up')\n", "\n", " def test_knapsack_top_down(self):\n", " knapsack = KnapsackTopDown()\n", - " assert_raises(TypeError, knapsack.fill_knapsack, None, None)\n", - " assert_equal(knapsack.fill_knapsack(0, 0), 0)\n", + " self.assertRaises(TypeError, knapsack.fill_knapsack, None, None)\n", + " self.assertEqual(knapsack.fill_knapsack(0, 0), 0)\n", " items = []\n", " items.append(Item(label='a', value=2, weight=2))\n", " items.append(Item(label='b', value=4, weight=2))\n", @@ -378,7 +368,7 @@ " items.append(Item(label='d', value=9, weight=5))\n", " total_weight = 8\n", " expected_value = 13\n", - " assert_equal(knapsack.fill_knapsack(items, total_weight), expected_value)\n", + " self.assertEqual(knapsack.fill_knapsack(items, total_weight), expected_value)\n", " print('Success: test_knapsack_top_down')\n", "\n", "def main():\n", @@ -394,9 +384,7 @@ { "cell_type": "code", "execution_count": 6, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -428,9 +416,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/knapsack_01/test_knapsack.py b/recursion_dynamic/knapsack_01/test_knapsack.py index 5388b1b..84ab437 100644 --- a/recursion_dynamic/knapsack_01/test_knapsack.py +++ b/recursion_dynamic/knapsack_01/test_knapsack.py @@ -1,12 +1,12 @@ -from nose.tools import assert_equal, assert_raises +import unittest -class TestKnapsack(object): +class TestKnapsack(unittest.TestCase): def test_knapsack_bottom_up(self): knapsack = Knapsack() - assert_raises(TypeError, knapsack.fill_knapsack, None, None) - assert_equal(knapsack.fill_knapsack(0, 0), 0) + self.assertRaises(TypeError, knapsack.fill_knapsack, None, None) + self.assertEqual(knapsack.fill_knapsack(0, 0), 0) items = [] items.append(Item(label='a', value=2, weight=2)) items.append(Item(label='b', value=4, weight=2)) @@ -15,18 +15,18 @@ class TestKnapsack(object): total_weight = 8 expected_value = 13 results = knapsack.fill_knapsack(items, total_weight) - assert_equal(results[0].label, 'd') - assert_equal(results[1].label, 'b') + self.assertEqual(results[0].label, 'd') + self.assertEqual(results[1].label, 'b') total_value = 0 for item in results: total_value += item.value - assert_equal(total_value, expected_value) + self.assertEqual(total_value, expected_value) print('Success: test_knapsack_bottom_up') def test_knapsack_top_down(self): knapsack = KnapsackTopDown() - assert_raises(TypeError, knapsack.fill_knapsack, None, None) - assert_equal(knapsack.fill_knapsack(0, 0), 0) + self.assertRaises(TypeError, knapsack.fill_knapsack, None, None) + self.assertEqual(knapsack.fill_knapsack(0, 0), 0) items = [] items.append(Item(label='a', value=2, weight=2)) items.append(Item(label='b', value=4, weight=2)) @@ -34,7 +34,7 @@ class TestKnapsack(object): items.append(Item(label='d', value=9, weight=5)) total_weight = 8 expected_value = 13 - assert_equal(knapsack.fill_knapsack(items, total_weight), expected_value) + self.assertEqual(knapsack.fill_knapsack(items, total_weight), expected_value) print('Success: test_knapsack_top_down') def main(): @@ -44,4 +44,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/knapsack_unbounded/knapsack_unbounded_challenge.ipynb b/recursion_dynamic/knapsack_unbounded/knapsack_unbounded_challenge.ipynb index b651724..b5dcc91 100644 --- a/recursion_dynamic/knapsack_unbounded/knapsack_unbounded_challenge.ipynb +++ b/recursion_dynamic/knapsack_unbounded/knapsack_unbounded_challenge.ipynb @@ -111,9 +111,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Knapsack(object):\n", @@ -140,21 +138,19 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_knapsack_unbounded.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestKnapsack(object):\n", + "class TestKnapsack(unittest.TestCase):\n", "\n", " def test_knapsack(self):\n", " knapsack = Knapsack()\n", - " assert_raises(TypeError, knapsack.fill_knapsack, None, None)\n", - " assert_equal(knapsack.fill_knapsack(0, 0), 0)\n", + " self.assertRaises(TypeError, knapsack.fill_knapsack, None, None)\n", + " self.assertEqual(knapsack.fill_knapsack(0, 0), 0)\n", " items = []\n", " items.append(Item(label='a', value=1, weight=1))\n", " items.append(Item(label='b', value=3, weight=2))\n", @@ -165,7 +161,7 @@ " total_weight = 7\n", " expected_value = 11\n", " results = knapsack.fill_knapsack(items, total_weight)\n", - " assert_equal(results, expected_value)\n", + " self.assertEqual(results, expected_value)\n", " print('Success: test_knapsack')\n", "\n", "def main():\n", @@ -203,9 +199,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/knapsack_unbounded/knapsack_unbounded_solution.ipynb b/recursion_dynamic/knapsack_unbounded/knapsack_unbounded_solution.ipynb index 867a00c..a1bf466 100644 --- a/recursion_dynamic/knapsack_unbounded/knapsack_unbounded_solution.ipynb +++ b/recursion_dynamic/knapsack_unbounded/knapsack_unbounded_solution.ipynb @@ -150,9 +150,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "class Item(object):\n", @@ -176,9 +174,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Knapsack(object):\n", @@ -209,9 +205,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -223,15 +217,15 @@ ], "source": [ "%%writefile test_knapsack_unbounded.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestKnapsack(object):\n", + "class TestKnapsack(unittest.TestCase):\n", "\n", " def test_knapsack(self):\n", " knapsack = Knapsack()\n", - " assert_raises(TypeError, knapsack.fill_knapsack, None, None)\n", - " assert_equal(knapsack.fill_knapsack(0, 0), 0)\n", + " self.assertRaises(TypeError, knapsack.fill_knapsack, None, None)\n", + " self.assertEqual(knapsack.fill_knapsack(0, 0), 0)\n", " items = []\n", " items.append(Item(label='a', value=1, weight=1))\n", " items.append(Item(label='b', value=3, weight=2))\n", @@ -242,7 +236,7 @@ " total_weight = 7\n", " expected_value = 11\n", " results = knapsack.fill_knapsack(items, total_weight)\n", - " assert_equal(results, expected_value)\n", + " self.assertEqual(results, expected_value)\n", " print('Success: test_knapsack')\n", "\n", "def main():\n", @@ -257,9 +251,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -290,9 +282,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/knapsack_unbounded/test_knapsack_unbounded.py b/recursion_dynamic/knapsack_unbounded/test_knapsack_unbounded.py index 141c7c8..0d2a94b 100644 --- a/recursion_dynamic/knapsack_unbounded/test_knapsack_unbounded.py +++ b/recursion_dynamic/knapsack_unbounded/test_knapsack_unbounded.py @@ -1,12 +1,12 @@ -from nose.tools import assert_equal, assert_raises +import unittest -class TestKnapsack(object): +class TestKnapsack(unittest.TestCase): def test_knapsack(self): knapsack = Knapsack() - assert_raises(TypeError, knapsack.fill_knapsack, None, None) - assert_equal(knapsack.fill_knapsack(0, 0), 0) + self.assertRaises(TypeError, knapsack.fill_knapsack, None, None) + self.assertEqual(knapsack.fill_knapsack(0, 0), 0) items = [] items.append(Item(label='a', value=1, weight=1)) items.append(Item(label='b', value=3, weight=2)) @@ -17,7 +17,7 @@ class TestKnapsack(object): total_weight = 7 expected_value = 11 results = knapsack.fill_knapsack(items, total_weight) - assert_equal(results, expected_value) + self.assertEqual(results, expected_value) print('Success: test_knapsack') def main(): @@ -26,4 +26,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/longest_common_subsequence/longest_common_subseq_challenge.ipynb b/recursion_dynamic/longest_common_subsequence/longest_common_subseq_challenge.ipynb index 531bdd4..21cd8a9 100644 --- a/recursion_dynamic/longest_common_subsequence/longest_common_subseq_challenge.ipynb +++ b/recursion_dynamic/longest_common_subsequence/longest_common_subseq_challenge.ipynb @@ -83,9 +83,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class StringCompare(object):\n", @@ -112,25 +110,23 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_longest_common_subseq.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestLongestCommonSubseq(object):\n", + "class TestLongestCommonSubseq(unittest.TestCase):\n", "\n", " def test_longest_common_subseq(self):\n", " str_comp = StringCompare()\n", - " assert_raises(TypeError, str_comp.longest_common_subseq, None, None)\n", - " assert_equal(str_comp.longest_common_subseq('', ''), '')\n", + " self.assertRaises(TypeError, str_comp.longest_common_subseq, None, None)\n", + " self.assertEqual(str_comp.longest_common_subseq('', ''), '')\n", " str0 = 'ABCDEFGHIJ'\n", " str1 = 'FOOBCDBCDE'\n", " expected = 'BCDE'\n", - " assert_equal(str_comp.longest_common_subseq(str0, str1), expected)\n", + " self.assertEqual(str_comp.longest_common_subseq(str0, str1), expected)\n", " print('Success: test_longest_common_subseq')\n", "\n", "\n", @@ -169,9 +165,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/longest_common_subsequence/longest_common_subseq_solution.ipynb b/recursion_dynamic/longest_common_subsequence/longest_common_subseq_solution.ipynb index 77d186f..bc82b66 100644 --- a/recursion_dynamic/longest_common_subsequence/longest_common_subseq_solution.ipynb +++ b/recursion_dynamic/longest_common_subsequence/longest_common_subseq_solution.ipynb @@ -116,9 +116,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class StringCompare(object):\n", @@ -169,9 +167,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -183,19 +179,19 @@ ], "source": [ "%%writefile test_longest_common_subseq.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestLongestCommonSubseq(object):\n", + "class TestLongestCommonSubseq(unittest.TestCase):\n", "\n", " def test_longest_common_subseq(self):\n", " str_comp = StringCompare()\n", - " assert_raises(TypeError, str_comp.longest_common_subseq, None, None)\n", - " assert_equal(str_comp.longest_common_subseq('', ''), '')\n", + " self.assertRaises(TypeError, str_comp.longest_common_subseq, None, None)\n", + " self.assertEqual(str_comp.longest_common_subseq('', ''), '')\n", " str0 = 'ABCDEFGHIJ'\n", " str1 = 'FOOBCDBCDE'\n", " expected = 'BCDE'\n", - " assert_equal(str_comp.longest_common_subseq(str0, str1), expected)\n", + " self.assertEqual(str_comp.longest_common_subseq(str0, str1), expected)\n", " print('Success: test_longest_common_subseq')\n", "\n", "\n", @@ -211,9 +207,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -244,9 +238,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/longest_common_subsequence/test_longest_common_subseq.py b/recursion_dynamic/longest_common_subsequence/test_longest_common_subseq.py index 6aa2e25..032fa54 100644 --- a/recursion_dynamic/longest_common_subsequence/test_longest_common_subseq.py +++ b/recursion_dynamic/longest_common_subsequence/test_longest_common_subseq.py @@ -1,16 +1,16 @@ -from nose.tools import assert_equal, assert_raises +import unittest -class TestLongestCommonSubseq(object): +class TestLongestCommonSubseq(unittest.TestCase): def test_longest_common_subseq(self): str_comp = StringCompare() - assert_raises(TypeError, str_comp.longest_common_subseq, None, None) - assert_equal(str_comp.longest_common_subseq('', ''), '') + self.assertRaises(TypeError, str_comp.longest_common_subseq, None, None) + self.assertEqual(str_comp.longest_common_subseq('', ''), '') str0 = 'ABCDEFGHIJ' str1 = 'FOOBCDBCDE' expected = 'BCDE' - assert_equal(str_comp.longest_common_subseq(str0, str1), expected) + self.assertEqual(str_comp.longest_common_subseq(str0, str1), expected) print('Success: test_longest_common_subseq') diff --git a/recursion_dynamic/longest_inc_subseq/longest_inc_subseq_challenge.ipynb b/recursion_dynamic/longest_inc_subseq/longest_inc_subseq_challenge.ipynb index dfe8d4d..5296943 100644 --- a/recursion_dynamic/longest_inc_subseq/longest_inc_subseq_challenge.ipynb +++ b/recursion_dynamic/longest_inc_subseq/longest_inc_subseq_challenge.ipynb @@ -76,9 +76,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Subsequence(object):\n", @@ -105,24 +103,22 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_longest_increasing_subseq.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestLongestIncreasingSubseq(object):\n", + "class TestLongestIncreasingSubseq(unittest.TestCase):\n", "\n", " def test_longest_increasing_subseq(self):\n", " subseq = Subsequence()\n", - " assert_raises(TypeError, subseq.longest_inc_subseq, None)\n", - " assert_equal(subseq.longest_inc_subseq([]), [])\n", + " self.assertRaises(TypeError, subseq.longest_inc_subseq, None)\n", + " self.assertEqual(subseq.longest_inc_subseq([]), [])\n", " seq = [3, 4, -1, 0, 6, 2, 3]\n", " expected = [-1, 0, 2, 3]\n", - " assert_equal(subseq.longest_inc_subseq(seq), expected)\n", + " self.assertEqual(subseq.longest_inc_subseq(seq), expected)\n", " print('Success: test_longest_increasing_subseq')\n", "\n", "\n", @@ -161,9 +157,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/longest_inc_subseq/longest_inc_subseq_solution.ipynb b/recursion_dynamic/longest_inc_subseq/longest_inc_subseq_solution.ipynb index a46c896..b84c93f 100644 --- a/recursion_dynamic/longest_inc_subseq/longest_inc_subseq_solution.ipynb +++ b/recursion_dynamic/longest_inc_subseq/longest_inc_subseq_solution.ipynb @@ -105,9 +105,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "class Subsequence(object):\n", @@ -149,9 +147,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -163,18 +159,18 @@ ], "source": [ "%%writefile test_longest_increasing_subseq.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestLongestIncreasingSubseq(object):\n", + "class TestLongestIncreasingSubseq(unittest.TestCase):\n", "\n", " def test_longest_increasing_subseq(self):\n", " subseq = Subsequence()\n", - " assert_raises(TypeError, subseq.longest_inc_subseq, None)\n", - " assert_equal(subseq.longest_inc_subseq([]), [])\n", + " self.assertRaises(TypeError, subseq.longest_inc_subseq, None)\n", + " self.assertEqual(subseq.longest_inc_subseq([]), [])\n", " seq = [3, 4, -1, 0, 6, 2, 3]\n", " expected = [-1, 0, 2, 3]\n", - " assert_equal(subseq.longest_inc_subseq(seq), expected)\n", + " self.assertEqual(subseq.longest_inc_subseq(seq), expected)\n", " print('Success: test_longest_increasing_subseq')\n", "\n", "\n", @@ -190,9 +186,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -223,9 +217,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/longest_inc_subseq/test_longest_increasing_subseq.py b/recursion_dynamic/longest_inc_subseq/test_longest_increasing_subseq.py index 7a0f9c0..e139999 100644 --- a/recursion_dynamic/longest_inc_subseq/test_longest_increasing_subseq.py +++ b/recursion_dynamic/longest_inc_subseq/test_longest_increasing_subseq.py @@ -1,15 +1,15 @@ -from nose.tools import assert_equal, assert_raises +import unittest -class TestLongestIncreasingSubseq(object): +class TestLongestIncreasingSubseq(unittest.TestCase): def test_longest_increasing_subseq(self): subseq = Subsequence() - assert_raises(TypeError, subseq.longest_inc_subseq, None) - assert_equal(subseq.longest_inc_subseq([]), []) + self.assertRaises(TypeError, subseq.longest_inc_subseq, None) + self.assertEqual(subseq.longest_inc_subseq([]), []) seq = [3, 4, -1, 0, 6, 2, 3] expected = [-1, 0, 2, 3] - assert_equal(subseq.longest_inc_subseq(seq), expected) + self.assertEqual(subseq.longest_inc_subseq(seq), expected) print('Success: test_longest_increasing_subseq') @@ -19,4 +19,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/longest_substr_k_distinct/longest_substr_challenge.ipynb b/recursion_dynamic/longest_substr_k_distinct/longest_substr_challenge.ipynb index 0636cdd..8386f16 100644 --- a/recursion_dynamic/longest_substr_k_distinct/longest_substr_challenge.ipynb +++ b/recursion_dynamic/longest_substr_k_distinct/longest_substr_challenge.ipynb @@ -79,9 +79,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Solution(object):\n", @@ -108,23 +106,21 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_longest_substr.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestSolution(object):\n", + "class TestSolution(unittest.TestCase):\n", "\n", " def test_longest_substr(self):\n", " solution = Solution()\n", - " assert_raises(TypeError, solution.longest_substr, None)\n", - " assert_equal(solution.longest_substr('', k=3), 0)\n", - " assert_equal(solution.longest_substr('abcabcdefgghiij', k=3), 6)\n", - " assert_equal(solution.longest_substr('abcabcdefgghighij', k=3), 7)\n", + " self.assertRaises(TypeError, solution.longest_substr, None)\n", + " self.assertEqual(solution.longest_substr('', k=3), 0)\n", + " self.assertEqual(solution.longest_substr('abcabcdefgghiij', k=3), 6)\n", + " self.assertEqual(solution.longest_substr('abcabcdefgghighij', k=3), 7)\n", " print('Success: test_longest_substr')\n", "\n", "\n", @@ -163,9 +159,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/longest_substr_k_distinct/longest_substr_solution.ipynb b/recursion_dynamic/longest_substr_k_distinct/longest_substr_solution.ipynb index bd71b1f..44fa7d3 100644 --- a/recursion_dynamic/longest_substr_k_distinct/longest_substr_solution.ipynb +++ b/recursion_dynamic/longest_substr_k_distinct/longest_substr_solution.ipynb @@ -92,9 +92,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Solution(object):\n", @@ -127,9 +125,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -141,17 +137,17 @@ ], "source": [ "%%writefile test_longest_substr.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestSolution(object):\n", + "class TestSolution(unittest.TestCase):\n", "\n", " def test_longest_substr(self):\n", " solution = Solution()\n", - " assert_raises(TypeError, solution.longest_substr, None)\n", - " assert_equal(solution.longest_substr('', k=3), 0)\n", - " assert_equal(solution.longest_substr('abcabcdefgghiij', k=3), 6)\n", - " assert_equal(solution.longest_substr('abcabcdefgghighij', k=3), 7)\n", + " self.assertRaises(TypeError, solution.longest_substr, None)\n", + " self.assertEqual(solution.longest_substr('', k=3), 0)\n", + " self.assertEqual(solution.longest_substr('abcabcdefgghiij', k=3), 6)\n", + " self.assertEqual(solution.longest_substr('abcabcdefgghighij', k=3), 7)\n", " print('Success: test_longest_substr')\n", "\n", "\n", @@ -167,9 +163,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -200,9 +194,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/longest_substr_k_distinct/test_longest_substr.py b/recursion_dynamic/longest_substr_k_distinct/test_longest_substr.py index 6410c7f..34e9e2a 100644 --- a/recursion_dynamic/longest_substr_k_distinct/test_longest_substr.py +++ b/recursion_dynamic/longest_substr_k_distinct/test_longest_substr.py @@ -1,14 +1,14 @@ -from nose.tools import assert_equal, assert_raises +import unittest -class TestSolution(object): +class TestSolution(unittest.TestCase): def test_longest_substr(self): solution = Solution() - assert_raises(TypeError, solution.longest_substr, None) - assert_equal(solution.longest_substr('', k=3), 0) - assert_equal(solution.longest_substr('abcabcdefgghiij', k=3), 6) - assert_equal(solution.longest_substr('abcabcdefgghighij', k=3), 7) + self.assertRaises(TypeError, solution.longest_substr, None) + self.assertEqual(solution.longest_substr('', k=3), 0) + self.assertEqual(solution.longest_substr('abcabcdefgghiij', k=3), 6) + self.assertEqual(solution.longest_substr('abcabcdefgghighij', k=3), 7) print('Success: test_longest_substr') @@ -18,4 +18,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/longest_substring/longest_common_substr_challenge.ipynb b/recursion_dynamic/longest_substring/longest_common_substr_challenge.ipynb index 77d4218..3833309 100644 --- a/recursion_dynamic/longest_substring/longest_common_substr_challenge.ipynb +++ b/recursion_dynamic/longest_substring/longest_common_substr_challenge.ipynb @@ -83,9 +83,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class StringCompare(object):\n", @@ -112,25 +110,23 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_longest_common_substr.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestLongestCommonSubstr(object):\n", + "class TestLongestCommonSubstr(unittest.TestCase):\n", "\n", " def test_longest_common_substr(self):\n", " str_comp = StringCompare()\n", - " assert_raises(TypeError, str_comp.longest_common_substr, None, None)\n", - " assert_equal(str_comp.longest_common_substr('', ''), '')\n", + " self.assertRaises(TypeError, str_comp.longest_common_substr, None, None)\n", + " self.assertEqual(str_comp.longest_common_substr('', ''), '')\n", " str0 = 'ABCDEFGHIJ'\n", " str1 = 'FOOBCDBCDE'\n", " expected = 'BCDE'\n", - " assert_equal(str_comp.longest_common_substr(str0, str1), expected)\n", + " self.assertEqual(str_comp.longest_common_substr(str0, str1), expected)\n", " print('Success: test_longest_common_substr')\n", "\n", "\n", @@ -169,9 +165,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/longest_substring/longest_common_substr_solution.ipynb b/recursion_dynamic/longest_substring/longest_common_substr_solution.ipynb index d3c4147..186020f 100644 --- a/recursion_dynamic/longest_substring/longest_common_substr_solution.ipynb +++ b/recursion_dynamic/longest_substring/longest_common_substr_solution.ipynb @@ -116,9 +116,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class StringCompare(object):\n", @@ -169,9 +167,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -183,19 +179,19 @@ ], "source": [ "%%writefile test_longest_common_substr.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestLongestCommonSubstr(object):\n", + "class TestLongestCommonSubstr(unittest.TestCase):\n", "\n", " def test_longest_common_substr(self):\n", " str_comp = StringCompare()\n", - " assert_raises(TypeError, str_comp.longest_common_substr, None, None)\n", - " assert_equal(str_comp.longest_common_substr('', ''), '')\n", + " self.assertRaises(TypeError, str_comp.longest_common_substr, None, None)\n", + " self.assertEqual(str_comp.longest_common_substr('', ''), '')\n", " str0 = 'ABCDEFGHIJ'\n", " str1 = 'FOOBCDBCDE'\n", " expected = 'BCDE'\n", - " assert_equal(str_comp.longest_common_substr(str0, str1), expected)\n", + " self.assertEqual(str_comp.longest_common_substr(str0, str1), expected)\n", " print('Success: test_longest_common_substr')\n", "\n", "\n", @@ -211,9 +207,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -244,9 +238,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/longest_substring/test_longest_common_substr.py b/recursion_dynamic/longest_substring/test_longest_common_substr.py index 8af8fe7..0241588 100644 --- a/recursion_dynamic/longest_substring/test_longest_common_substr.py +++ b/recursion_dynamic/longest_substring/test_longest_common_substr.py @@ -1,16 +1,16 @@ -from nose.tools import assert_equal, assert_raises +import unittest -class TestLongestCommonSubstr(object): +class TestLongestCommonSubstr(unittest.TestCase): def test_longest_common_substr(self): str_comp = StringCompare() - assert_raises(TypeError, str_comp.longest_common_substr, None, None) - assert_equal(str_comp.longest_common_substr('', ''), '') + self.assertRaises(TypeError, str_comp.longest_common_substr, None, None) + self.assertEqual(str_comp.longest_common_substr('', ''), '') str0 = 'ABCDEFGHIJ' str1 = 'FOOBCDBCDE' expected = 'BCDE' - assert_equal(str_comp.longest_common_substr(str0, str1), expected) + self.assertEqual(str_comp.longest_common_substr(str0, str1), expected) print('Success: test_longest_common_substr') @@ -20,4 +20,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/magic_index/magic_index_challenge.ipynb b/recursion_dynamic/magic_index/magic_index_challenge.ipynb index 3dc9734..d943c56 100644 --- a/recursion_dynamic/magic_index/magic_index_challenge.ipynb +++ b/recursion_dynamic/magic_index/magic_index_challenge.ipynb @@ -100,9 +100,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class MagicIndex(object):\n", @@ -129,27 +127,25 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_find_magic_index.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class TestFindMagicIndex(object):\n", + "class TestFindMagicIndex(unittest.TestCase):\n", "\n", " def test_find_magic_index(self):\n", " magic_index = MagicIndex()\n", - " assert_equal(magic_index.find_magic_index(None), -1)\n", - " assert_equal(magic_index.find_magic_index([]), -1)\n", + " self.assertEqual(magic_index.find_magic_index(None), -1)\n", + " self.assertEqual(magic_index.find_magic_index([]), -1)\n", " array = [-4, -2, 2, 6, 6, 6, 6, 10]\n", - " assert_equal(magic_index.find_magic_index(array), 2)\n", + " self.assertEqual(magic_index.find_magic_index(array), 2)\n", " array = [-4, -2, 1, 6, 6, 6, 6, 10]\n", - " assert_equal(magic_index.find_magic_index(array), 6)\n", + " self.assertEqual(magic_index.find_magic_index(array), 6)\n", " array = [-4, -2, 1, 6, 6, 6, 7, 10]\n", - " assert_equal(magic_index.find_magic_index(array), -1)\n", + " self.assertEqual(magic_index.find_magic_index(array), -1)\n", " print('Success: test_find_magic')\n", "\n", "\n", @@ -188,9 +184,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/magic_index/magic_index_solution.ipynb b/recursion_dynamic/magic_index/magic_index_solution.ipynb index eade7fc..8c3c1ce 100644 --- a/recursion_dynamic/magic_index/magic_index_solution.ipynb +++ b/recursion_dynamic/magic_index/magic_index_solution.ipynb @@ -129,9 +129,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "from __future__ import division\n", @@ -171,9 +169,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -185,21 +181,21 @@ ], "source": [ "%%writefile test_find_magic_index.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class TestFindMagicIndex(object):\n", + "class TestFindMagicIndex(unittest.TestCase):\n", "\n", " def test_find_magic_index(self):\n", " magic_index = MagicIndex()\n", - " assert_equal(magic_index.find_magic_index(None), -1)\n", - " assert_equal(magic_index.find_magic_index([]), -1)\n", + " self.assertEqual(magic_index.find_magic_index(None), -1)\n", + " self.assertEqual(magic_index.find_magic_index([]), -1)\n", " array = [-4, -2, 2, 6, 6, 6, 6, 10]\n", - " assert_equal(magic_index.find_magic_index(array), 2)\n", + " self.assertEqual(magic_index.find_magic_index(array), 2)\n", " array = [-4, -2, 1, 6, 6, 6, 6, 10]\n", - " assert_equal(magic_index.find_magic_index(array), 6)\n", + " self.assertEqual(magic_index.find_magic_index(array), 6)\n", " array = [-4, -2, 1, 6, 6, 6, 7, 10]\n", - " assert_equal(magic_index.find_magic_index(array), -1)\n", + " self.assertEqual(magic_index.find_magic_index(array), -1)\n", " print('Success: test_find_magic')\n", "\n", "\n", @@ -215,9 +211,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -248,9 +242,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/magic_index/test_find_magic_index.py b/recursion_dynamic/magic_index/test_find_magic_index.py index d6b1bb2..483a7aa 100644 --- a/recursion_dynamic/magic_index/test_find_magic_index.py +++ b/recursion_dynamic/magic_index/test_find_magic_index.py @@ -1,18 +1,18 @@ -from nose.tools import assert_equal +import unittest -class TestFindMagicIndex(object): +class TestFindMagicIndex(unittest.TestCase): def test_find_magic_index(self): magic_index = MagicIndex() - assert_equal(magic_index.find_magic_index(None), -1) - assert_equal(magic_index.find_magic_index([]), -1) + self.assertEqual(magic_index.find_magic_index(None), -1) + self.assertEqual(magic_index.find_magic_index([]), -1) array = [-4, -2, 2, 6, 6, 6, 6, 10] - assert_equal(magic_index.find_magic_index(array), 2) + self.assertEqual(magic_index.find_magic_index(array), 2) array = [-4, -2, 1, 6, 6, 6, 6, 10] - assert_equal(magic_index.find_magic_index(array), 6) + self.assertEqual(magic_index.find_magic_index(array), 6) array = [-4, -2, 1, 6, 6, 6, 7, 10] - assert_equal(magic_index.find_magic_index(array), -1) + self.assertEqual(magic_index.find_magic_index(array), -1) print('Success: test_find_magic') @@ -22,4 +22,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/matrix_mult/find_min_cost_challenge.ipynb b/recursion_dynamic/matrix_mult/find_min_cost_challenge.ipynb index 5f4a260..fb87f21 100644 --- a/recursion_dynamic/matrix_mult/find_min_cost_challenge.ipynb +++ b/recursion_dynamic/matrix_mult/find_min_cost_challenge.ipynb @@ -87,9 +87,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class MatrixMultiplicationCost(object):\n", @@ -116,27 +114,25 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_find_min_cost.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestMatrixMultiplicationCost(object):\n", + "class TestMatrixMultiplicationCost(unittest.TestCase):\n", "\n", " def test_find_min_cost(self):\n", " matrix_mult_cost = MatrixMultiplicationCost()\n", - " assert_raises(TypeError, matrix_mult_cost.find_min_cost, None)\n", - " assert_equal(matrix_mult_cost.find_min_cost([]), 0)\n", + " self.assertRaises(TypeError, matrix_mult_cost.find_min_cost, None)\n", + " self.assertEqual(matrix_mult_cost.find_min_cost([]), 0)\n", " matrices = [Matrix(2, 3),\n", " Matrix(3, 6),\n", " Matrix(6, 4),\n", " Matrix(4, 5)]\n", " expected_cost = 124\n", - " assert_equal(matrix_mult_cost.find_min_cost(matrices), expected_cost)\n", + " self.assertEqual(matrix_mult_cost.find_min_cost(matrices), expected_cost)\n", " print('Success: test_find_min_cost')\n", "\n", "\n", @@ -175,9 +171,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/matrix_mult/find_min_cost_solution.ipynb b/recursion_dynamic/matrix_mult/find_min_cost_solution.ipynb index 7eb3c9a..5eb950e 100644 --- a/recursion_dynamic/matrix_mult/find_min_cost_solution.ipynb +++ b/recursion_dynamic/matrix_mult/find_min_cost_solution.ipynb @@ -174,9 +174,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "class Matrix(object):\n", @@ -189,9 +187,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "import sys\n", @@ -231,9 +227,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -245,21 +239,21 @@ ], "source": [ "%%writefile test_find_min_cost.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestMatrixMultiplicationCost(object):\n", + "class TestMatrixMultiplicationCost(unittest.TestCase):\n", "\n", " def test_find_min_cost(self):\n", " matrix_mult_cost = MatrixMultiplicationCost()\n", - " assert_raises(TypeError, matrix_mult_cost.find_min_cost, None)\n", - " assert_equal(matrix_mult_cost.find_min_cost([]), 0)\n", + " self.assertRaises(TypeError, matrix_mult_cost.find_min_cost, None)\n", + " self.assertEqual(matrix_mult_cost.find_min_cost([]), 0)\n", " matrices = [Matrix(2, 3),\n", " Matrix(3, 6),\n", " Matrix(6, 4),\n", " Matrix(4, 5)]\n", " expected_cost = 124\n", - " assert_equal(matrix_mult_cost.find_min_cost(matrices), expected_cost)\n", + " self.assertEqual(matrix_mult_cost.find_min_cost(matrices), expected_cost)\n", " print('Success: test_find_min_cost')\n", "\n", "\n", @@ -275,9 +269,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -308,9 +300,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/matrix_mult/test_find_min_cost.py b/recursion_dynamic/matrix_mult/test_find_min_cost.py index 20c4cc8..d5aa267 100644 --- a/recursion_dynamic/matrix_mult/test_find_min_cost.py +++ b/recursion_dynamic/matrix_mult/test_find_min_cost.py @@ -1,18 +1,18 @@ -from nose.tools import assert_equal, assert_raises +import unittest -class TestMatrixMultiplicationCost(object): +class TestMatrixMultiplicationCost(unittest.TestCase): def test_find_min_cost(self): matrix_mult_cost = MatrixMultiplicationCost() - assert_raises(TypeError, matrix_mult_cost.find_min_cost, None) - assert_equal(matrix_mult_cost.find_min_cost([]), 0) + self.assertRaises(TypeError, matrix_mult_cost.find_min_cost, None) + self.assertEqual(matrix_mult_cost.find_min_cost([]), 0) matrices = [Matrix(2, 3), Matrix(3, 6), Matrix(6, 4), Matrix(4, 5)] expected_cost = 124 - assert_equal(matrix_mult_cost.find_min_cost(matrices), expected_cost) + self.assertEqual(matrix_mult_cost.find_min_cost(matrices), expected_cost) print('Success: test_find_min_cost') @@ -22,4 +22,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/max_profit_k/max_profit_challenge.ipynb b/recursion_dynamic/max_profit_k/max_profit_challenge.ipynb index 94291e6..c565d7a 100644 --- a/recursion_dynamic/max_profit_k/max_profit_challenge.ipynb +++ b/recursion_dynamic/max_profit_k/max_profit_challenge.ipynb @@ -124,9 +124,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class StockTrader(object):\n", @@ -153,45 +151,41 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_max_profit.py\n", - "from nose.tools import assert_equal\n", - "from nose.tools import assert_raises\n", - "from nose.tools import assert_true\n", + "import unittest\n", "\n", "\n", - "class TestMaxProfit(object):\n", + "class TestMaxProfit(unittest.TestCase):\n", "\n", " def test_max_profit(self):\n", " stock_trader = StockTrader()\n", - " assert_raises(TypeError, stock_trader.find_max_profit, None, None)\n", - " assert_equal(stock_trader.find_max_profit(prices=[], k=0), [])\n", + " self.assertRaises(TypeError, stock_trader.find_max_profit, None, None)\n", + " self.assertEqual(stock_trader.find_max_profit(prices=[], k=0), [])\n", " prices = [5, 4, 3, 2, 1]\n", " k = 3\n", - " assert_equal(stock_trader.find_max_profit(prices, k), (0, []))\n", + " self.assertEqual(stock_trader.find_max_profit(prices, k), (0, []))\n", " prices = [2, 5, 7, 1, 4, 3, 1, 3]\n", " profit, transactions = stock_trader.find_max_profit(prices, k)\n", - " assert_equal(profit, 10)\n", - " assert_true(Transaction(Type.SELL,\n", + " self.assertEqual(profit, 10)\n", + " self.assertTrue(Transaction(Type.SELL,\n", " day=7,\n", " price=3) in transactions)\n", - " assert_true(Transaction(Type.BUY,\n", + " self.assertTrue(Transaction(Type.BUY,\n", " day=6,\n", " price=1) in transactions)\n", - " assert_true(Transaction(Type.SELL,\n", + " self.assertTrue(Transaction(Type.SELL,\n", " day=4,\n", " price=4) in transactions)\n", - " assert_true(Transaction(Type.BUY,\n", + " self.assertTrue(Transaction(Type.BUY,\n", " day=3,\n", " price=1) in transactions)\n", - " assert_true(Transaction(Type.SELL,\n", + " self.assertTrue(Transaction(Type.SELL,\n", " day=2,\n", " price=7) in transactions)\n", - " assert_true(Transaction(Type.BUY,\n", + " self.assertTrue(Transaction(Type.BUY,\n", " day=0,\n", " price=2) in transactions)\n", " print('Success: test_max_profit')\n", @@ -232,9 +226,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/max_profit_k/max_profit_solution.ipynb b/recursion_dynamic/max_profit_k/max_profit_solution.ipynb index fe9b866..b9ce656 100644 --- a/recursion_dynamic/max_profit_k/max_profit_solution.ipynb +++ b/recursion_dynamic/max_profit_k/max_profit_solution.ipynb @@ -123,9 +123,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "from enum import Enum # Python 2 users: Run pip install enum34\n", @@ -157,9 +155,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "import sys\n", @@ -241,9 +237,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -255,39 +249,37 @@ ], "source": [ "%%writefile test_max_profit.py\n", - "from nose.tools import assert_equal\n", - "from nose.tools import assert_raises\n", - "from nose.tools import assert_true\n", + "import unittest\n", "\n", "\n", - "class TestMaxProfit(object):\n", + "class TestMaxProfit(unittest.TestCase):\n", "\n", " def test_max_profit(self):\n", " stock_trader = StockTrader()\n", - " assert_raises(TypeError, stock_trader.find_max_profit, None, None)\n", - " assert_equal(stock_trader.find_max_profit(prices=[], k=0), [])\n", + " self.assertRaises(TypeError, stock_trader.find_max_profit, None, None)\n", + " self.assertEqual(stock_trader.find_max_profit(prices=[], k=0), [])\n", " prices = [5, 4, 3, 2, 1]\n", " k = 3\n", - " assert_equal(stock_trader.find_max_profit(prices, k), (0, []))\n", + " self.assertEqual(stock_trader.find_max_profit(prices, k), (0, []))\n", " prices = [2, 5, 7, 1, 4, 3, 1, 3]\n", " profit, transactions = stock_trader.find_max_profit(prices, k)\n", - " assert_equal(profit, 10)\n", - " assert_true(Transaction(Type.SELL,\n", + " self.assertEqual(profit, 10)\n", + " self.assertTrue(Transaction(Type.SELL,\n", " day=7,\n", " price=3) in transactions)\n", - " assert_true(Transaction(Type.BUY,\n", + " self.assertTrue(Transaction(Type.BUY,\n", " day=6,\n", " price=1) in transactions)\n", - " assert_true(Transaction(Type.SELL,\n", + " self.assertTrue(Transaction(Type.SELL,\n", " day=4,\n", " price=4) in transactions)\n", - " assert_true(Transaction(Type.BUY,\n", + " self.assertTrue(Transaction(Type.BUY,\n", " day=3,\n", " price=1) in transactions)\n", - " assert_true(Transaction(Type.SELL,\n", + " self.assertTrue(Transaction(Type.SELL,\n", " day=2,\n", " price=7) in transactions)\n", - " assert_true(Transaction(Type.BUY,\n", + " self.assertTrue(Transaction(Type.BUY,\n", " day=0,\n", " price=2) in transactions)\n", " print('Success: test_max_profit')\n", @@ -305,9 +297,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -338,9 +328,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/max_profit_k/test_max_profit.py b/recursion_dynamic/max_profit_k/test_max_profit.py index bd21cc1..dfadcf1 100644 --- a/recursion_dynamic/max_profit_k/test_max_profit.py +++ b/recursion_dynamic/max_profit_k/test_max_profit.py @@ -1,36 +1,34 @@ -from nose.tools import assert_equal -from nose.tools import assert_raises -from nose.tools import assert_true +import unittest -class TestMaxProfit(object): +class TestMaxProfit(unittest.TestCase): def test_max_profit(self): stock_trader = StockTrader() - assert_raises(TypeError, stock_trader.find_max_profit, None, None) - assert_equal(stock_trader.find_max_profit(prices=[], k=0), []) + self.assertRaises(TypeError, stock_trader.find_max_profit, None, None) + self.assertEqual(stock_trader.find_max_profit(prices=[], k=0), []) prices = [5, 4, 3, 2, 1] k = 3 - assert_equal(stock_trader.find_max_profit(prices, k), (0, [])) + self.assertEqual(stock_trader.find_max_profit(prices, k), (0, [])) prices = [2, 5, 7, 1, 4, 3, 1, 3] profit, transactions = stock_trader.find_max_profit(prices, k) - assert_equal(profit, 10) - assert_true(Transaction(Type.SELL, + self.assertEqual(profit, 10) + self.assertTrue(Transaction(Type.SELL, day=7, price=3) in transactions) - assert_true(Transaction(Type.BUY, + self.assertTrue(Transaction(Type.BUY, day=6, price=1) in transactions) - assert_true(Transaction(Type.SELL, + self.assertTrue(Transaction(Type.SELL, day=4, price=4) in transactions) - assert_true(Transaction(Type.BUY, + self.assertTrue(Transaction(Type.BUY, day=3, price=1) in transactions) - assert_true(Transaction(Type.SELL, + self.assertTrue(Transaction(Type.SELL, day=2, price=7) in transactions) - assert_true(Transaction(Type.BUY, + self.assertTrue(Transaction(Type.BUY, day=0, price=2) in transactions) print('Success: test_max_profit') @@ -42,4 +40,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/n_pairs_parentheses/n_pairs_parentheses_challenge.ipynb b/recursion_dynamic/n_pairs_parentheses/n_pairs_parentheses_challenge.ipynb index f7a3e77..c016798 100644 --- a/recursion_dynamic/n_pairs_parentheses/n_pairs_parentheses_challenge.ipynb +++ b/recursion_dynamic/n_pairs_parentheses/n_pairs_parentheses_challenge.ipynb @@ -103,26 +103,24 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_n_pairs_parentheses.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestPairParentheses(object):\n", + "class TestPairParentheses(unittest.TestCase):\n", "\n", " def test_pair_parentheses(self):\n", " parentheses = Parentheses()\n", - " assert_raises(TypeError, parentheses.find_pair, None)\n", - " assert_raises(ValueError, parentheses.find_pair, -1)\n", - " assert_equal(parentheses.find_pair(0), [])\n", - " assert_equal(parentheses.find_pair(1), ['()'])\n", - " assert_equal(parentheses.find_pair(2), ['(())',\n", + " self.assertRaises(TypeError, parentheses.find_pair, None)\n", + " self.assertRaises(ValueError, parentheses.find_pair, -1)\n", + " self.assertEqual(parentheses.find_pair(0), [])\n", + " self.assertEqual(parentheses.find_pair(1), ['()'])\n", + " self.assertEqual(parentheses.find_pair(2), ['(())',\n", " '()()'])\n", - " assert_equal(parentheses.find_pair(3), ['((()))',\n", + " self.assertEqual(parentheses.find_pair(3), ['((()))',\n", " '(()())',\n", " '(())()',\n", " '()(())',\n", @@ -165,9 +163,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/n_pairs_parentheses/n_pairs_parentheses_solution.ipynb b/recursion_dynamic/n_pairs_parentheses/n_pairs_parentheses_solution.ipynb index a122861..40b6fe6 100644 --- a/recursion_dynamic/n_pairs_parentheses/n_pairs_parentheses_solution.ipynb +++ b/recursion_dynamic/n_pairs_parentheses/n_pairs_parentheses_solution.ipynb @@ -98,9 +98,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "class Parentheses(object):\n", @@ -137,9 +135,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -151,20 +147,20 @@ ], "source": [ "%%writefile test_n_pairs_parentheses.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestPairParentheses(object):\n", + "class TestPairParentheses(unittest.TestCase):\n", "\n", " def test_pair_parentheses(self):\n", " parentheses = Parentheses()\n", - " assert_raises(TypeError, parentheses.find_pair, None)\n", - " assert_raises(ValueError, parentheses.find_pair, -1)\n", - " assert_equal(parentheses.find_pair(0), [])\n", - " assert_equal(parentheses.find_pair(1), ['()'])\n", - " assert_equal(parentheses.find_pair(2), ['(())',\n", + " self.assertRaises(TypeError, parentheses.find_pair, None)\n", + " self.assertRaises(ValueError, parentheses.find_pair, -1)\n", + " self.assertEqual(parentheses.find_pair(0), [])\n", + " self.assertEqual(parentheses.find_pair(1), ['()'])\n", + " self.assertEqual(parentheses.find_pair(2), ['(())',\n", " '()()'])\n", - " assert_equal(parentheses.find_pair(3), ['((()))',\n", + " self.assertEqual(parentheses.find_pair(3), ['((()))',\n", " '(()())',\n", " '(())()',\n", " '()(())',\n", @@ -184,9 +180,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -217,9 +211,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/n_pairs_parentheses/test_n_pairs_parentheses.py b/recursion_dynamic/n_pairs_parentheses/test_n_pairs_parentheses.py index 8c2ab34..5eab056 100644 --- a/recursion_dynamic/n_pairs_parentheses/test_n_pairs_parentheses.py +++ b/recursion_dynamic/n_pairs_parentheses/test_n_pairs_parentheses.py @@ -1,17 +1,17 @@ -from nose.tools import assert_equal, assert_raises +import unittest -class TestPairParentheses(object): +class TestPairParentheses(unittest.TestCase): def test_pair_parentheses(self): parentheses = Parentheses() - assert_raises(TypeError, parentheses.find_pair, None) - assert_raises(ValueError, parentheses.find_pair, -1) - assert_equal(parentheses.find_pair(0), []) - assert_equal(parentheses.find_pair(1), ['()']) - assert_equal(parentheses.find_pair(2), ['(())', + self.assertRaises(TypeError, parentheses.find_pair, None) + self.assertRaises(ValueError, parentheses.find_pair, -1) + self.assertEqual(parentheses.find_pair(0), []) + self.assertEqual(parentheses.find_pair(1), ['()']) + self.assertEqual(parentheses.find_pair(2), ['(())', '()()']) - assert_equal(parentheses.find_pair(3), ['((()))', + self.assertEqual(parentheses.find_pair(3), ['((()))', '(()())', '(())()', '()(())', @@ -25,4 +25,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/permutations/permutations_challenge.ipynb b/recursion_dynamic/permutations/permutations_challenge.ipynb index 696ccdb..342f612 100644 --- a/recursion_dynamic/permutations/permutations_challenge.ipynb +++ b/recursion_dynamic/permutations/permutations_challenge.ipynb @@ -82,9 +82,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Permutations(object):\n", @@ -111,28 +109,26 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_permutations.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class TestPermutations(object):\n", + "class TestPermutations(unittest.TestCase):\n", "\n", " def test_permutations(self):\n", " permutations = Permutations()\n", - " assert_equal(permutations.find_permutations(None), None)\n", - " assert_equal(permutations.find_permutations(''), '')\n", + " self.assertEqual(permutations.find_permutations(None), None)\n", + " self.assertEqual(permutations.find_permutations(''), '')\n", " string = 'AABC'\n", " expected = [\n", " 'AABC', 'AACB', 'ABAC', 'ABCA',\n", " 'ACAB', 'ACBA', 'BAAC', 'BACA',\n", " 'BCAA', 'CAAB', 'CABA', 'CBAA'\n", " ]\n", - " assert_equal(permutations.find_permutations(string), expected)\n", + " self.assertEqual(permutations.find_permutations(string), expected)\n", " print('Success: test_permutations')\n", "\n", "\n", @@ -171,9 +167,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/permutations/permutations_solution.ipynb b/recursion_dynamic/permutations/permutations_solution.ipynb index 3e1c8e6..8a74a2f 100644 --- a/recursion_dynamic/permutations/permutations_solution.ipynb +++ b/recursion_dynamic/permutations/permutations_solution.ipynb @@ -94,9 +94,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "from collections import OrderedDict\n", @@ -148,9 +146,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -162,22 +158,22 @@ ], "source": [ "%%writefile test_permutations.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class TestPermutations(object):\n", + "class TestPermutations(unittest.TestCase):\n", "\n", " def test_permutations(self):\n", " permutations = Permutations()\n", - " assert_equal(permutations.find_permutations(None), None)\n", - " assert_equal(permutations.find_permutations(''), '')\n", + " self.assertEqual(permutations.find_permutations(None), None)\n", + " self.assertEqual(permutations.find_permutations(''), '')\n", " string = 'AABC'\n", " expected = [\n", " 'AABC', 'AACB', 'ABAC', 'ABCA',\n", " 'ACAB', 'ACBA', 'BAAC', 'BACA',\n", " 'BCAA', 'CAAB', 'CABA', 'CBAA'\n", " ]\n", - " assert_equal(permutations.find_permutations(string), expected)\n", + " self.assertEqual(permutations.find_permutations(string), expected)\n", " print('Success: test_permutations')\n", "\n", "\n", @@ -193,9 +189,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -226,9 +220,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/permutations/test_permutations.py b/recursion_dynamic/permutations/test_permutations.py index b319ac5..1dfbd16 100644 --- a/recursion_dynamic/permutations/test_permutations.py +++ b/recursion_dynamic/permutations/test_permutations.py @@ -1,19 +1,19 @@ -from nose.tools import assert_equal +import unittest -class TestPermutations(object): +class TestPermutations(unittest.TestCase): def test_permutations(self): permutations = Permutations() - assert_equal(permutations.find_permutations(None), None) - assert_equal(permutations.find_permutations(''), '') + self.assertEqual(permutations.find_permutations(None), None) + self.assertEqual(permutations.find_permutations(''), '') string = 'AABC' expected = [ 'AABC', 'AACB', 'ABAC', 'ABCA', 'ACAB', 'ACBA', 'BAAC', 'BACA', 'BCAA', 'CAAB', 'CABA', 'CBAA' ] - assert_equal(permutations.find_permutations(string), expected) + self.assertEqual(permutations.find_permutations(string), expected) print('Success: test_permutations') @@ -23,4 +23,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/power_set/power_set_challenge.ipynb b/recursion_dynamic/power_set/power_set_challenge.ipynb index 907b56c..4d62c18 100644 --- a/recursion_dynamic/power_set/power_set_challenge.ipynb +++ b/recursion_dynamic/power_set/power_set_challenge.ipynb @@ -91,9 +91,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Sets(object):\n", @@ -124,16 +122,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_power_set.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class TestPowerSet(object):\n", + "class TestPowerSet(unittest.TestCase):\n", "\n", " def test_power_set(self):\n", " input_set = []\n", @@ -154,9 +150,9 @@ " def run_test(self, input_set, expected):\n", " combinatoric = Combinatoric()\n", " result = combinatoric.find_power_set_recursive(input_set)\n", - " assert_equal(result, expected)\n", + " self.assertEqual(result, expected)\n", " result = combinatoric.find_power_set_iterative(input_set)\n", - " assert_equal(result, expected)\n", + " self.assertEqual(result, expected)\n", "\n", "\n", "def main():\n", @@ -194,9 +190,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/power_set/power_set_solution.ipynb b/recursion_dynamic/power_set/power_set_solution.ipynb index 3197e23..991b527 100644 --- a/recursion_dynamic/power_set/power_set_solution.ipynb +++ b/recursion_dynamic/power_set/power_set_solution.ipynb @@ -115,9 +115,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "from collections import OrderedDict\n", @@ -171,9 +169,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -185,10 +181,10 @@ ], "source": [ "%%writefile test_power_set.py\n", - "from nose.tools import assert_equal\n", + "import unittest\n", "\n", "\n", - "class TestPowerSet(object):\n", + "class TestPowerSet(unittest.TestCase):\n", "\n", " def test_power_set(self):\n", " input_set = ''\n", @@ -214,7 +210,7 @@ " def run_test(self, input_set, expected):\n", " combinatoric = Combinatoric()\n", " result = combinatoric.find_power_set(input_set)\n", - " assert_equal(result, expected)\n", + " self.assertEqual(result, expected)\n", "\n", "\n", "def main():\n", @@ -229,9 +225,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -262,9 +256,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/power_set/test_power_set.py b/recursion_dynamic/power_set/test_power_set.py index e64b59e..37b953e 100644 --- a/recursion_dynamic/power_set/test_power_set.py +++ b/recursion_dynamic/power_set/test_power_set.py @@ -1,7 +1,7 @@ -from nose.tools import assert_equal +import unittest -class TestPowerSet(object): +class TestPowerSet(unittest.TestCase): def test_power_set(self): input_set = '' @@ -27,7 +27,7 @@ class TestPowerSet(object): def run_test(self, input_set, expected): combinatoric = Combinatoric() result = combinatoric.find_power_set(input_set) - assert_equal(result, expected) + self.assertEqual(result, expected) def main(): @@ -36,4 +36,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/recursion_dynamic/steps/steps_challenge.ipynb b/recursion_dynamic/steps/steps_challenge.ipynb index b1eb3d2..5ea3714 100644 --- a/recursion_dynamic/steps/steps_challenge.ipynb +++ b/recursion_dynamic/steps/steps_challenge.ipynb @@ -76,9 +76,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Steps(object):\n", @@ -105,27 +103,25 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# %load test_steps.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestSteps(object):\n", + "class TestSteps(unittest.TestCase):\n", "\n", " def test_steps(self):\n", " steps = Steps()\n", - " assert_raises(TypeError, steps.count_ways, None)\n", - " assert_raises(TypeError, steps.count_ways, -1)\n", - " assert_equal(steps.count_ways(0), 1)\n", - " assert_equal(steps.count_ways(1), 1)\n", - " assert_equal(steps.count_ways(2), 2)\n", - " assert_equal(steps.count_ways(3), 4)\n", - " assert_equal(steps.count_ways(4), 7)\n", - " assert_equal(steps.count_ways(10), 274)\n", + " self.assertRaises(TypeError, steps.count_ways, None)\n", + " self.assertRaises(TypeError, steps.count_ways, -1)\n", + " self.assertEqual(steps.count_ways(0), 1)\n", + " self.assertEqual(steps.count_ways(1), 1)\n", + " self.assertEqual(steps.count_ways(2), 2)\n", + " self.assertEqual(steps.count_ways(3), 4)\n", + " self.assertEqual(steps.count_ways(4), 7)\n", + " self.assertEqual(steps.count_ways(10), 274)\n", " print('Success: test_steps')\n", "\n", "\n", @@ -164,9 +160,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/steps/steps_solution.ipynb b/recursion_dynamic/steps/steps_solution.ipynb index be65d1c..7ebf7e0 100644 --- a/recursion_dynamic/steps/steps_solution.ipynb +++ b/recursion_dynamic/steps/steps_solution.ipynb @@ -107,9 +107,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "class Steps(object):\n", @@ -143,9 +141,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -157,21 +153,21 @@ ], "source": [ "%%writefile test_steps.py\n", - "from nose.tools import assert_equal, assert_raises\n", + "import unittest\n", "\n", "\n", - "class TestSteps(object):\n", + "class TestSteps(unittest.TestCase):\n", "\n", " def test_steps(self):\n", " steps = Steps()\n", - " assert_raises(TypeError, steps.count_ways, None)\n", - " assert_raises(TypeError, steps.count_ways, -1)\n", - " assert_equal(steps.count_ways(0), 1)\n", - " assert_equal(steps.count_ways(1), 1)\n", - " assert_equal(steps.count_ways(2), 2)\n", - " assert_equal(steps.count_ways(3), 4)\n", - " assert_equal(steps.count_ways(4), 7)\n", - " assert_equal(steps.count_ways(10), 274)\n", + " self.assertRaises(TypeError, steps.count_ways, None)\n", + " self.assertRaises(TypeError, steps.count_ways, -1)\n", + " self.assertEqual(steps.count_ways(0), 1)\n", + " self.assertEqual(steps.count_ways(1), 1)\n", + " self.assertEqual(steps.count_ways(2), 2)\n", + " self.assertEqual(steps.count_ways(3), 4)\n", + " self.assertEqual(steps.count_ways(4), 7)\n", + " self.assertEqual(steps.count_ways(10), 274)\n", " print('Success: test_steps')\n", "\n", "\n", @@ -187,9 +183,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -220,9 +214,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.0" + "version": "3.7.2" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/recursion_dynamic/steps/test_steps.py b/recursion_dynamic/steps/test_steps.py index d506287..7976994 100644 --- a/recursion_dynamic/steps/test_steps.py +++ b/recursion_dynamic/steps/test_steps.py @@ -1,18 +1,18 @@ -from nose.tools import assert_equal, assert_raises +import unittest -class TestSteps(object): +class TestSteps(unittest.TestCase): def test_steps(self): steps = Steps() - assert_raises(TypeError, steps.count_ways, None) - assert_raises(TypeError, steps.count_ways, -1) - assert_equal(steps.count_ways(0), 1) - assert_equal(steps.count_ways(1), 1) - assert_equal(steps.count_ways(2), 2) - assert_equal(steps.count_ways(3), 4) - assert_equal(steps.count_ways(4), 7) - assert_equal(steps.count_ways(10), 274) + self.assertRaises(TypeError, steps.count_ways, None) + self.assertRaises(TypeError, steps.count_ways, -1) + self.assertEqual(steps.count_ways(0), 1) + self.assertEqual(steps.count_ways(1), 1) + self.assertEqual(steps.count_ways(2), 2) + self.assertEqual(steps.count_ways(3), 4) + self.assertEqual(steps.count_ways(4), 7) + self.assertEqual(steps.count_ways(10), 274) print('Success: test_steps') @@ -22,4 +22,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main()