Skip to content

Commit b5311b8

Browse files
authored
Merge pull request #668 from sir-gon/develop
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Arrays: Left Rota…
2 parents 2f1b6f3 + 2bf1d8f commit b5311b8

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
[
2-
{"input": [1, 2, 3, 4, 5], "expected": [2, 3, 4, 5, 1]},
3-
{"input": [2, 3, 4, 5, 1], "expected": [3, 4, 5, 1, 2]},
4-
{"input": [3, 4, 5, 1, 2], "expected": [4, 5, 1, 2, 3]},
5-
{"input": [4, 5, 1, 2, 3], "expected": [5, 1, 2, 3, 4]},
6-
{"input": [5, 1, 2, 3, 4], "expected": [1, 2, 3, 4, 5]}
2+
{"title": "Own 0", "input": [1, 2, 3, 4, 5], "d_rotations": 1, "expected": [2, 3, 4, 5, 1]},
3+
{"title": "Own 1", "input": [2, 3, 4, 5, 1], "d_rotations": 1, "expected": [3, 4, 5, 1, 2]},
4+
{"title": "Own 2", "input": [3, 4, 5, 1, 2], "d_rotations": 1, "expected": [4, 5, 1, 2, 3]},
5+
{"title": "Own 3", "input": [4, 5, 1, 2, 3], "d_rotations": 1, "expected": [5, 1, 2, 3, 4]},
6+
{"title": "Own 4", "input": [5, 1, 2, 3, 4], "d_rotations": 1, "expected": [1, 2, 3, 4, 5]},
7+
{"title": "Sample Test case 0", "input": [1, 2, 3, 4, 5], "d_rotations": 4, "expected": [5, 1, 2, 3, 4]},
8+
{"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]},
9+
{"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]}
710
]

src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation_test.py

+4-16
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pathlib import Path
33

44
from ....lib.loader import loadTestCases
5-
from .ctci_array_left_rotation import rotLeft, rotLeftOne
5+
from .ctci_array_left_rotation import rotLeft
66

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

@@ -12,23 +12,11 @@
1212

1313
class TestArrayLeftRotation(unittest.TestCase):
1414

15-
def test_rot_left_one(self):
16-
for _, _tt in enumerate(TEST_CASES):
17-
18-
self.assertEqual(
19-
rotLeftOne(_tt['input']), _tt['expected'],
20-
f"{_} | rotLeftOne({_tt['input']}) must be "
21-
f"=> {_tt['expected']}")
22-
2315
def test_rot_left(self):
2416

25-
tests = [
26-
{'input': [1, 2, 3, 4, 5], 'd': 4, 'expected': [5, 1, 2, 3, 4]},
27-
]
28-
29-
for _, _tt in enumerate(tests):
17+
for _, _tt in enumerate(TEST_CASES):
3018

3119
self.assertEqual(
32-
rotLeft(_tt['input'], _tt['d']), _tt['expected'],
33-
f"{_} | rotLeft({_tt['input']}) must be "
20+
rotLeft(_tt['input'], _tt['d_rotations']), _tt['expected'],
21+
f"{_} | rotLeft({_tt['input'], _tt['d_rotations']}) must be "
3422
f"=> {_tt['expected']}")

0 commit comments

Comments
 (0)