From 556a9adc11eb8245514f0d58c55b04a06cb2fec6 Mon Sep 17 00:00:00 2001 From: William Chargin Date: Tue, 4 Apr 2017 05:58:53 -0400 Subject: [PATCH] Add duplicate-characters test for permutations (#158) Summary: The current test cases for the "string permutation checker" problem do not include a test case where the inputs have the same elements at different multiplicities. Without this test case, the implementation return s1 is not None and s2 is not None and set(s1) == set(s2) would pass all tests. Test Plan: First, change one of the implementations to the above implementation, and see that the original tests still pass. Then, apply this patch to add the new test case. Then, revert the implementation change to see all tests pass again. --- arrays_strings/permutation/permutation_solution.ipynb | 4 +++- arrays_strings/permutation/test_permutation_solution.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arrays_strings/permutation/permutation_solution.ipynb b/arrays_strings/permutation/permutation_solution.ipynb index 1ec421c..2cca059 100644 --- a/arrays_strings/permutation/permutation_solution.ipynb +++ b/arrays_strings/permutation/permutation_solution.ipynb @@ -58,7 +58,8 @@ "* One or more empty strings -> False\n", "* 'Nib', 'bin' -> False\n", "* 'act', 'cat' -> True\n", - "* 'a ct', 'ca t' -> True" + "* 'a ct', 'ca t' -> True\n", + "* 'dog', 'doggo' -> False" ] }, { @@ -200,6 +201,7 @@ " assert_equal(func('Nib', 'bin'), False)\n", " assert_equal(func('act', 'cat'), True)\n", " assert_equal(func('a ct', 'ca t'), True)\n", + " assert_equal(func('dog', 'doggo'), False)\n", " print('Success: test_permutation')\n", "\n", "\n", diff --git a/arrays_strings/permutation/test_permutation_solution.py b/arrays_strings/permutation/test_permutation_solution.py index 8320cfd..9ab124c 100644 --- a/arrays_strings/permutation/test_permutation_solution.py +++ b/arrays_strings/permutation/test_permutation_solution.py @@ -9,6 +9,7 @@ class TestPermutation(object): assert_equal(func('Nib', 'bin'), False) assert_equal(func('act', 'cat'), True) assert_equal(func('a ct', 'ca t'), True) + assert_equal(func('dog', 'doggo'), False) print('Success: test_permutation')