mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 10:58:02 +00:00
Add permutations challenge
This commit is contained in:
26
recursion_dynamic/permutations/test_permutations.py
Normal file
26
recursion_dynamic/permutations/test_permutations.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from nose.tools import assert_equal
|
||||
|
||||
|
||||
class TestPermutations(object):
|
||||
|
||||
def test_permutations(self):
|
||||
permutations = Permutations()
|
||||
assert_equal(permutations.find_permutations(None), None)
|
||||
assert_equal(permutations.find_permutations(''), '')
|
||||
string = 'AABC'
|
||||
expected = [
|
||||
'AABC', 'AACB', 'ABAC', 'ABCA',
|
||||
'ACAB', 'ACBA', 'BAAC', 'BACA',
|
||||
'BCAA', 'CAAB', 'CABA', 'CBAA'
|
||||
]
|
||||
assert_equal(permutations.find_permutations(string), expected)
|
||||
print('Success: test_permutations')
|
||||
|
||||
|
||||
def main():
|
||||
test = TestPermutations()
|
||||
test.test_permutations()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user