Skip to content

Commit 191bc5a

Browse files
committed
ffff
1 parent 45fdcce commit 191bc5a

File tree

5 files changed

+59
-19
lines changed

5 files changed

+59
-19
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"ponicode.testSettings.testLocation.locationType": "Same folder as source file",
3-
"ponicode.testSettings.testLocation.path": "{rootDir}/{filePath}/{fileName}.test.{ext}"
3+
"ponicode.testSettings.testLocation.path": "{rootDir}/{filePath}/{fileName}.test.{ext}",
4+
"python.pythonPath": ".venv/bin/python3.9"
45
}

data_structures_and_algorithms/challenges/array_reverse/array_reverse.py

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def array_shift(l,b):
2+
middle = len(l) // 2
3+
if len(l) % 2 == 0:
4+
5+
return l[:middle] + [b] + l[middle:]
6+
else:
7+
return l[:middle + 1] + [b] + l[middle +1:]
8+

tests/challenges/test_array_reverse.py

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# put your array_reverse challenge tests here
2+
from data_structures_and_algorithms.challenges.array_reverse.array_shift import array_shift
3+
4+
5+
# "Happy Path" cases
6+
# test should pass for array with number of even element where elements are integers
7+
def test_one():
8+
expected = [1,2,5,3,4]
9+
actual = array_shift([1,2,3,4],5)
10+
assert actual == expected
11+
12+
# test should pass for array with number of even element where elements are letters
13+
def test_two():
14+
expected = ['a','b','z','c','d']
15+
actual = array_shift(['a','b','c','d'],'z')
16+
assert actual == expected
17+
18+
# test should pass for array with odd number of elements where elements are letters and integers
19+
def test_three():
20+
expected = [1,2,3,'a',4,5]
21+
actual = array_shift([1,2,3,4,5],'a')
22+
assert actual == expected
23+
24+
25+
26+
# Edge Case
27+
# test should pass for initial array with only 2 elements
28+
def test_four():
29+
expected = [1,2,1]
30+
actual = array_shift([1,1],2)
31+
assert actual == expected
32+
33+
34+
35+
# Expected Failure
36+
# test should pass for initial array with elements ptinted with spaces
37+
def test_five():
38+
expected = [1,2,9,3]
39+
actual = array_shift([ 1 , 2 , 3 ],9)
40+
assert actual == expected
41+
42+
# test should pass for initial array with only one element
43+
def test_six():
44+
expected = [1,2]
45+
actual = array_shift([1],2)
46+
assert actual == expected
47+
48+
49+

0 commit comments

Comments
 (0)