diff options
Diffstat (limited to 'challenge-307/roger-bell-west/python/ch-2.py')
| -rwxr-xr-x | challenge-307/roger-bell-west/python/ch-2.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-307/roger-bell-west/python/ch-2.py b/challenge-307/roger-bell-west/python/ch-2.py new file mode 100755 index 0000000000..155ecdbd29 --- /dev/null +++ b/challenge-307/roger-bell-west/python/ch-2.py @@ -0,0 +1,21 @@ +#! /usr/bin/python3 + +def findanagrams(a): + b = ["".join(sorted(s)) for s in a] + out = 1 + for i in range(1, len(b)): + if b[i - 1] != b[i]: + out += 1 + return out + +import unittest + +class TestFindanagrams(unittest.TestCase): + + def test_ex1(self): + self.assertEqual(findanagrams(["acca", "dog", "god", "perl", "repl"]), 3, 'example 1') + + def test_ex2(self): + self.assertEqual(findanagrams(["abba", "baba", "aabb", "ab", "ab"]), 2, 'example 2') + +unittest.main() |
