def unit_test_permutations(): assert sorted(permute('j')) == ['j'] assert sorted(permute('dog')) == sorted( ['dog', 'dgo', 'odg', 'ogd', 'god', 'gdo']) assert sorted(permute('aabc')) == sorted([ 'aabc', 'aacb', 'abac', 'abca', 'acab', 'acba', 'baac', 'baca', 'bcaa', 'caab', 'caba', 'cbaa' ]) assert [w for w in permute('bac') ] == ['bac', 'bca', 'abc', 'acb', 'cba', 'cab']
def test_three_word_case(self): ''' test that when passed HAT the function returns all permutations of HAT (in correct order) ''' string = 'HAT' expected = ['HAT', 'HTA', 'AHT', 'ATH', 'THA', 'TAH'] self.assertEqual(permute(string), expected)
def totalRange(e): ways = pr.permute(e) total = [] for way in ways: y = addAllOpers(way) for z in y: total += solveAllWays(z) return cleanList(total)
def test_permutations_2(self): inputList = [6, 5, 4] outputList = [ [6, 5, 4], [6, 4, 5], [5, 6, 4], [5, 4, 6], [4, 6, 5], # ispravljen zarez [4, 5, 6] ] self.assertEqual(permute(inputList), outputList)
def unit_test_ith_permutation(): assert ith_permutation(0, 'abc') == 'abc' assert ith_permutation(0, 'bac') == 'abc' assert ith_permutation(0, 'cba') == 'abc' assert ith_permutation(1, 'bac') == 'acb' for i, permutation in enumerate(permute('abc')): assert ith_permutation(i, 'cba') == permutation assert ith_permutation(0, 'abac') == 'aabc' assert ith_permutation(1, 'abac') == 'aacb' assert ith_permutation(6, 'abac') == 'baac' assert ith_permutation(11, 'abac') == 'cbaa' assert ith_permutation(12, 'abac') == 'aabc'
pass line = "{}`{}`{}\n".format(path, title, result_url) q.append(line) print(line) if __name__ == '__main__': letters = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ] perms = permutations.permute(2, letters) perms = list(map(lambda s: 'Z' + s, perms)) # print("Parsing {} URLs.".format(len(perms))) tr = Thread(target=write_file) tr.start() pool = mp.Pool(mp.cpu_count() - 1) pool.map(parse_url, [path for path in perms]) pool.close() done = True tr.join() # print("Done! wrote output to beaves_out.csv")
def test_permutations_1(self): inputList = [1, 2, 3] outputList = [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]] self.assertEqual(permute(inputList), outputList)
def createPents(): a = [x for x in range(1,10)] perms = [list2Pent(b + [10]) for b in pr.permute(a) if legitPent(list2Pent(b + [10]))] return perms
def test_empty_permute(self): results = permute([]) assert results == []
def test_permutations(self): results = permute([1,2]) print results assert results == [[1,2],[2,1]]
def test_trailing(self): results = permute([1,]) assert results == [1]
def test_permutations(self): self.assertEqual( [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 2, 1], [3, 1, 2]], permute([1, 2, 3]))