diff --git a/arrays_strings/permutation/permutation_challenge.ipynb b/arrays_strings/permutation/permutation_challenge.ipynb index ce31923..05426fb 100644 --- a/arrays_strings/permutation/permutation_challenge.ipynb +++ b/arrays_strings/permutation/permutation_challenge.ipynb @@ -40,6 +40,10 @@ "* Is whitespace important?\n", " * Yes\n", "* Is this case sensitive? 'Nib', 'bin' is not a match?\n", + " * Yes\n", + "* Can we use additional data structures?\n", + " * Yes\n", + "* Can we assume this fits in memory?\n", " * Yes" ] }, @@ -49,6 +53,7 @@ "source": [ "## Test Cases\n", "\n", + "* One or more None inputs -> False\n", "* One or more empty strings -> False\n", "* 'Nib', 'bin' -> False\n", "* 'act', 'cat' -> True\n", @@ -115,6 +120,7 @@ "class TestPermutation(object):\n", "\n", " def test_permutation(self, func):\n", + " assert_equal(func(None, 'foo'), False)\n", " assert_equal(func('', 'foo'), False)\n", " assert_equal(func('Nib', 'bin'), False)\n", " assert_equal(func('act', 'cat'), True)\n", @@ -149,21 +155,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" + "pygments_lexer": "ipython3", + "version": "3.5.0" } }, "nbformat": 4, diff --git a/arrays_strings/permutation/permutation_solution.ipynb b/arrays_strings/permutation/permutation_solution.ipynb index 23be349..5348686 100644 --- a/arrays_strings/permutation/permutation_solution.ipynb +++ b/arrays_strings/permutation/permutation_solution.ipynb @@ -41,6 +41,10 @@ "* Is whitespace important?\n", " * Yes\n", "* Is this case sensitive? 'Nib', 'bin' is not a match?\n", + " * Yes\n", + "* Can we use additional data structures?\n", + " * Yes\n", + "* Can we assume this fits in memory?\n", " * Yes" ] }, @@ -50,6 +54,7 @@ "source": [ "## Test Cases\n", "\n", + "* One or more None inputs -> False\n", "* One or more empty strings -> False\n", "* 'Nib', 'bin' -> False\n", "* 'act', 'cat' -> True\n", @@ -91,6 +96,8 @@ "outputs": [], "source": [ "def permutations(str1, str2):\n", + " if str1 is None or str2 is None:\n", + " return False\n", " return sorted(str1) == sorted(str2)" ] }, @@ -141,6 +148,8 @@ "\n", "\n", "def permutations_alt(str1, str2):\n", + " if str1 is None or str2 is None:\n", + " return False\n", " if len(str1) != len(str2):\n", " return False\n", " unique_counts1 = defaultdict(int)\n", @@ -182,6 +191,7 @@ "class TestPermutation(object):\n", "\n", " def test_permutation(self, func):\n", + " assert_equal(func(None, 'foo'), False)\n", " assert_equal(func('', 'foo'), False)\n", " assert_equal(func('Nib', 'bin'), False)\n", " assert_equal(func('act', 'cat'), True)\n", diff --git a/arrays_strings/permutation/test_permutation_solution.py b/arrays_strings/permutation/test_permutation_solution.py index 9e14427..23929a5 100644 --- a/arrays_strings/permutation/test_permutation_solution.py +++ b/arrays_strings/permutation/test_permutation_solution.py @@ -4,6 +4,7 @@ from nose.tools import assert_equal class TestPermutation(object): def test_permutation(self, func): + assert_equal(func(None, 'foo'), False) assert_equal(func('', 'foo'), False) assert_equal(func('Nib', 'bin'), False) assert_equal(func('act', 'cat'), True)