Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[
{"input": [1, 2, 3, 4, 5], "expected": [2, 3, 4, 5, 1]},
{"input": [2, 3, 4, 5, 1], "expected": [3, 4, 5, 1, 2]},
{"input": [3, 4, 5, 1, 2], "expected": [4, 5, 1, 2, 3]},
{"input": [4, 5, 1, 2, 3], "expected": [5, 1, 2, 3, 4]},
{"input": [5, 1, 2, 3, 4], "expected": [1, 2, 3, 4, 5]}
{"title": "Own 0", "input": [1, 2, 3, 4, 5], "d_rotations": 1, "expected": [2, 3, 4, 5, 1]},
{"title": "Own 1", "input": [2, 3, 4, 5, 1], "d_rotations": 1, "expected": [3, 4, 5, 1, 2]},
{"title": "Own 2", "input": [3, 4, 5, 1, 2], "d_rotations": 1, "expected": [4, 5, 1, 2, 3]},
{"title": "Own 3", "input": [4, 5, 1, 2, 3], "d_rotations": 1, "expected": [5, 1, 2, 3, 4]},
{"title": "Own 4", "input": [5, 1, 2, 3, 4], "d_rotations": 1, "expected": [1, 2, 3, 4, 5]},
{"title": "Sample Test case 0", "input": [1, 2, 3, 4, 5], "d_rotations": 4, "expected": [5, 1, 2, 3, 4]},
{"title": "Sample Test case 1", "input": [41, 73, 89, 7, 10, 1, 59, 58, 84, 77, 77, 97, 58, 1, 86, 58, 26, 10, 86, 51], "d_rotations": 10, "expected": [77, 97, 58, 1, 86, 58, 26, 10, 86, 51, 41, 73, 89, 7, 10, 1, 59, 58, 84, 77]},
{"title": "Sample Test case 2", "input": [33, 47, 70, 37, 8, 53, 13, 93, 71, 72, 51, 100, 60, 87, 97], "d_rotations": 13, "expected": [87, 97, 33, 47, 70, 37, 8, 53, 13, 93, 71, 72, 51, 100, 60]}
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path

from ....lib.loader import loadTestCases
from .ctci_array_left_rotation import rotLeft, rotLeftOne
from .ctci_array_left_rotation import rotLeft

FILE_PATH = str(Path(__file__).resolve().parent)

Expand All @@ -12,23 +12,11 @@

class TestArrayLeftRotation(unittest.TestCase):

def test_rot_left_one(self):
for _, _tt in enumerate(TEST_CASES):

self.assertEqual(
rotLeftOne(_tt['input']), _tt['expected'],
f"{_} | rotLeftOne({_tt['input']}) must be "
f"=> {_tt['expected']}")

def test_rot_left(self):

tests = [
{'input': [1, 2, 3, 4, 5], 'd': 4, 'expected': [5, 1, 2, 3, 4]},
]

for _, _tt in enumerate(tests):
for _, _tt in enumerate(TEST_CASES):

self.assertEqual(
rotLeft(_tt['input'], _tt['d']), _tt['expected'],
f"{_} | rotLeft({_tt['input']}) must be "
rotLeft(_tt['input'], _tt['d_rotations']), _tt['expected'],
f"{_} | rotLeft({_tt['input'], _tt['d_rotations']}) must be "
f"=> {_tt['expected']}")