-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## Permutations | ||
|
||
In this kata you have to create all permutations of an input string and remove duplicates, if present. This means, you have to shuffle all letters from the input in all possible orders. | ||
|
||
### Examples: | ||
|
||
```bash | ||
permutations('a'); # ['a'] | ||
permutations('ab'); # ['ab', 'ba'] | ||
permutations('aabb'); # ['aabb', 'abab', 'abba', 'baab', 'baba', 'bbaa'] | ||
``` | ||
|
||
The order of the permutations doesn't matter. | ||
|
||
[Source](https://www.codewars.com/kata/5254ca2719453dcc0b00027d/train/python) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Created by Egor Kostan. | ||
# GitHub: https://github.com/ikostan | ||
# LinkedIn: https://www.linkedin.com/in/egor-kostan/ | ||
|
||
|
||
def permutations(string) -> list: | ||
""" | ||
creates all permutations of an input string and | ||
remove duplicates, if present. This means, you | ||
have to shuffle all letters from the input in all | ||
possible orders. | ||
""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Created by Egor Kostan. | ||
# GitHub: https://github.com/ikostan | ||
# LinkedIn: https://www.linkedin.com/in/egor-kostan/ | ||
|
||
# ALGORITHMS PERMUTATIONS STRINGS | ||
|
||
import allure | ||
import unittest | ||
import pytest | ||
from utils.log_func import print_log | ||
from kyu_4.permutations.permutations import permutations | ||
|
||
|
||
@allure.epic("4 kyu") | ||
@allure.parent_suite('Competent') | ||
@allure.suite("Algorithms") | ||
@allure.sub_suite("Unit Tests") | ||
@allure.feature("String") | ||
@allure.story("Permutations") | ||
@pytest.mark.skip(reason="The solution is not ready") | ||
class PermutationsTestCase(unittest.TestCase): | ||
|
||
def test_permutations(self): | ||
""" | ||
Testing permutations function | ||
Test that permutations function creates all | ||
permutations of an input string and | ||
remove duplicates, if present. This means, you | ||
have to shuffle all letters from the input in all | ||
possible orders. | ||
""" | ||
|
||
allure.dynamic.title("Testing permutations function") | ||
allure.dynamic.severity(allure.severity_level.NORMAL) | ||
|
||
with allure.step("Enter a test string and verify the output"): | ||
test_data = [ | ||
('a', ['a']), | ||
('ab', ['ab', 'ba']), | ||
('aabb', ['aabb', 'abab', 'abba', 'baab', 'baba', 'bbaa']), | ||
('abc', ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']), | ||
('abcd', ['abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', | ||
'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', | ||
'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', | ||
'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba']), | ||
('dcba', ['abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', | ||
'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', | ||
'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', | ||
'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba']) | ||
] | ||
|
||
for string, expected in test_data: | ||
|
||
print_log(string=string, | ||
expected=expected) | ||
|
||
self.assertListEqual(sorted(expected), | ||
sorted(permutations(string))) |
f155431
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy detected an issue:
Message:
Unnecessary pass statement
Occurred on:
pass
Currently on: