def test_anagrams(self): # fmi/sample_test.py words = ['army', 'mary', 'ramy', 'astronomer', 'moonstarer', 'debit card', 'bad credit', 'bau'] anagrams = [['army', 'mary', 'ramy'], ['bad credit', 'debit card'], ['astronomer', 'moonstarer'], ['bau']] self.assertEqual( set(map(frozenset, anagrams)), set(map(frozenset, solution.anagrams(words)))) # stoyaneft/tests.py words = ['listen', 'are', 'pets', 'inlets', 'ear', 'enlist', 'step', 'pest', 'silent', 'tinsel', 'ERA'] anagrams = [['listen', 'inlets', 'enlist', 'silent', 'tinsel'], ['are', 'ear', 'ERA'], ['pets', 'step', 'pest']] self.assertEqual( set(map(frozenset, anagrams)), set(map(frozenset, solution.anagrams(words)))) # Ralitsa-Ts/tests.py words = ['woman Hitler', 'the eyes', 'dormitory', 'mother-in-law', 'dirty room', 'they see'] anagrams = [['woman Hitler', 'mother-in-law'], ['the eyes', 'they see'], ['dormitory', 'dirty room']] self.assertEqual( set(map(frozenset, anagrams)), set(map(frozenset, solution.anagrams(words))))
def test_with_different_cases(self): words = ["Dave Barry", "Ray Adverb"] anagrams = [["Dave Barry", "Ray Adverb"]] self.assertEqual( set(map(frozenset, anagrams)), set(map(frozenset, solution.anagrams(words))))
def test_with_list_of_cyrilic_anagrams(self): words = ['кавалер', 'акварел'] anagrams = [['кавалер', 'акварел']] self.assertEqual( set(map(frozenset, anagrams)), set(map(frozenset, solution.anagrams(words))))
def test_anagrams(self): words = ['army', 'mary', 'ramy', 'astronomer', 'moonstarer', 'debit card', 'bad credit', 'bau'] anagrams = [['army', 'mary', 'ramy'], ['bad credit', 'debit card'], ['astronomer', 'moonstarer'], ['bau']] self.assertEqual(set(map(frozenset, anagrams)),set(map(frozenset, solution.anagrams(words))))
def test_with_different_symbols(self): words = ["Tom Marvolo Riddle", "I am Lord Voldemort", "Tom Cruise", "So I'm cuter"] anagrams = [["Tom Marvolo Riddle", "I am Lord Voldemort"], ["Tom Cruise", "So I'm cuter"]] self.assertEqual( set(map(frozenset, anagrams)), set(map(frozenset, solution.anagrams(words))))
def test_anagrams(self): words = [ 'army', 'mary', 'ramy', 'astronomer', 'moonstarer', 'debit card', 'bad credit', 'bau' ] anagrams = [['army', 'mary', 'ramy'], ['bad credit', 'debit card'], ['astronomer', 'moonstarer'], ['bau']] self.assertEqual(set(map(frozenset, anagrams)), set(map(frozenset, solution.anagrams(words))))
def test_anagrams_3(self): words = ["Election results", "Stolen cruelties.", "Lies – let\'s recount", "Halley\'s Comet", "Shall yet come", "Conversation", "Voices rant on", "Fir cones", "Conifers"] anagrams = [["Election results", "Stolen cruelties.", "Lies – let\'s recount"], ["Halley\'s Comet", "Shall yet come"], ["Conversation", "Voices rant on"], ["Fir cones", "Conifers"]] self.assertEqual( set(map(frozenset, anagrams)), set(map(frozenset, solution.anagrams(words))))
def test_anagrams_0(self): words = ["To be or not to be: that is the question; whether" " \'tis nobler in the mind to suffer the slings and arrows" " of outrageous fortune...", "In one of the Bard\'s best-thought-of tragedies our" " insistent hero, Hamlet, queries on two fronts about" " how life turns rotten.", "wow"] anagrams = [["To be or not to be: that is the question; whether" " \'tis nobler in the mind to suffer the slings and" " arrows of outrageous fortune...", "In one of the Bard\'s best-thought-of tragedies our" " insistent hero, Hamlet, queries on two fronts about" " how life turns rotten."], ["wow"]] self.assertEqual(set(map(frozenset, anagrams)),set(map(frozenset, solution.anagrams(words))))
def test_anagrams_1(self): words = [("To be or not to be: that is the question; whether \'tis" " nobler in the mind to suffer the slings and arrows of" " outrageous fortune, or to take arms against a sea of" " troubles and by opposing, end them?"), ("Is a befitting quote from one of Shakespeare\'s greatest" " tragedies. But why won\'t Hamlet\'s inspiring motto toss" " our stubborn hero\'s tortuous battle for life, on one" " hand, and death, on another?"), "such string"] anagrams = [[("To be or not to be: that is the question; whether \'" "tis nobler in the mind to suffer the slings and arrows" " of outrageous fortune, or to take arms against a sea" " of troubles and by opposing, end them?"), ("Is a befitting quote from one of Shakespeare\'s" " greatest tragedies. But why won\'t Hamlet\'s inspiring" " motto toss our stubborn hero\'s tortuous battle for" " life, on one hand, and death, on another?")], ["such string"]] self.assertEqual( set(map(frozenset, anagrams)), set(map(frozenset, solution.anagrams(words))))
def test_anagrams(word, words, result): assert anagrams(word, words) == result
def test(self): self.assertEqual(solution.anagrams('abba', ['aabb', 'abcd', 'bbaa', 'dada']), ['aabb', 'bbaa']) self.assertEqual(solution.anagrams('racer', ['crazer', 'carer', 'racar', 'caers', 'racer']), ['carer', 'racer'])
import solution input = ["art", "rat", "bats", "banana", "stab", "tar"] print solution.anagrams(input) print solution.anagrams_ordered(input)
def test_anagrams_2(self): words = ['wamаn hitler', 'the eyes', 'dormitory', 'mаther-in-law','dirty room', 'they see'] anagrams = [['wamаn hitler', 'mаther-in-law'],['the eyes', 'they see'],['dormitory', 'dirty room']] self.assertEqual(set(map(frozenset, anagrams)),set(map(frozenset, solution.anagrams(words))))