diff --git a/.vscode/settings.json b/.vscode/settings.json index 506fdf7..0effd91 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { "ponicode.testSettings.testLocation.locationType": "Same folder as source file", - "ponicode.testSettings.testLocation.path": "{rootDir}/{filePath}/{fileName}.test.{ext}" + "ponicode.testSettings.testLocation.path": "{rootDir}/{filePath}/{fileName}.test.{ext}", + "python.pythonPath": ".venv/bin/python3.9" } \ No newline at end of file diff --git a/README.md b/README.md index cce2048..857a1f0 100644 --- a/README.md +++ b/README.md @@ -1 +1,9 @@ -# data-structures-and-algorithms-python \ No newline at end of file +# data-structures-and-algorithms-python +# Challenge Summary +IT was eady +## Challenge Description +I did a tests to a shift array +## Approach & Efficiency +TDD +## Solution +![Getting Started](dddddddddddd.png) \ No newline at end of file diff --git a/data_structures_and_algorithms/__pycache__/__init__.cpython-38.pyc b/data_structures_and_algorithms/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..6cd44d6 Binary files /dev/null and b/data_structures_and_algorithms/__pycache__/__init__.cpython-38.pyc differ diff --git a/data_structures_and_algorithms/challenges/array_reverse/__pycache__/array_shift.cpython-38.pyc b/data_structures_and_algorithms/challenges/array_reverse/__pycache__/array_shift.cpython-38.pyc new file mode 100644 index 0000000..13062e0 Binary files /dev/null and b/data_structures_and_algorithms/challenges/array_reverse/__pycache__/array_shift.cpython-38.pyc differ diff --git a/data_structures_and_algorithms/challenges/array_reverse/array_reverse.py b/data_structures_and_algorithms/challenges/array_reverse/array_reverse.py deleted file mode 100644 index 2d95a3f..0000000 --- a/data_structures_and_algorithms/challenges/array_reverse/array_reverse.py +++ /dev/null @@ -1,8 +0,0 @@ -def reverse_array(arr): - - arr = arr[::-1] - - return arr - - - print(arr) diff --git a/data_structures_and_algorithms/challenges/array_reverse/array_shift.py b/data_structures_and_algorithms/challenges/array_reverse/array_shift.py new file mode 100644 index 0000000..0b06801 --- /dev/null +++ b/data_structures_and_algorithms/challenges/array_reverse/array_shift.py @@ -0,0 +1,8 @@ +def array_shift(l,b): + middle = len(l) // 2 + if len(l) % 2 == 0: + + return l[:middle] + [b] + l[middle:] + else: + return l[:middle + 1] + [b] + l[middle +1:] + diff --git a/data_structures_and_algorithms/challenges/array_reverse/lab01.png b/data_structures_and_algorithms/challenges/array_reverse/lab01.png deleted file mode 100644 index 6404a5d..0000000 Binary files a/data_structures_and_algorithms/challenges/array_reverse/lab01.png and /dev/null differ diff --git a/data_structures_and_algorithms/data_structures/linked_list/__pycache__/linked_list.cpython-38.pyc b/data_structures_and_algorithms/data_structures/linked_list/__pycache__/linked_list.cpython-38.pyc new file mode 100644 index 0000000..d4bbf7a Binary files /dev/null and b/data_structures_and_algorithms/data_structures/linked_list/__pycache__/linked_list.cpython-38.pyc differ diff --git a/dddddddddddd.png b/dddddddddddd.png new file mode 100644 index 0000000..b0f0cb5 Binary files /dev/null and b/dddddddddddd.png differ diff --git a/tests/__pycache__/__init__.cpython-38.pyc b/tests/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..9933114 Binary files /dev/null and b/tests/__pycache__/__init__.cpython-38.pyc differ diff --git a/tests/__pycache__/test_data_structures_and_algorithms.cpython-38-pytest-6.1.2.pyc b/tests/__pycache__/test_data_structures_and_algorithms.cpython-38-pytest-6.1.2.pyc new file mode 100644 index 0000000..acb6354 Binary files /dev/null and b/tests/__pycache__/test_data_structures_and_algorithms.cpython-38-pytest-6.1.2.pyc differ diff --git a/tests/challenges/__pycache__/test_array_shift.cpython-38-pytest-6.1.2.pyc b/tests/challenges/__pycache__/test_array_shift.cpython-38-pytest-6.1.2.pyc new file mode 100644 index 0000000..7a70476 Binary files /dev/null and b/tests/challenges/__pycache__/test_array_shift.cpython-38-pytest-6.1.2.pyc differ diff --git a/tests/challenges/test_array_reverse.py b/tests/challenges/test_array_reverse.py deleted file mode 100644 index 3eb0054..0000000 --- a/tests/challenges/test_array_reverse.py +++ /dev/null @@ -1,10 +0,0 @@ -# put your array_reverse challenge tests here -from data_structures_and_algorithms.challenges.array_reverse.array_reverse import ( - reverse_array, -) - -# here's a test to get you started -def test_leave_as_is(): - actual = reverse_array([1]) - expected = [1] - assert actual == expected diff --git a/tests/challenges/test_array_shift.py b/tests/challenges/test_array_shift.py new file mode 100644 index 0000000..fdd2d32 --- /dev/null +++ b/tests/challenges/test_array_shift.py @@ -0,0 +1,49 @@ +# put your array_reverse challenge tests here +from data_structures_and_algorithms.challenges.array_reverse.array_shift import array_shift + + +# "Happy Path" cases +# test should pass for array with number of even element where elements are integers +def test_one(): + expected = [1,2,5,3,4] + actual = array_shift([1,2,3,4],5) + assert actual == expected + +# test should pass for array with number of even element where elements are letters +def test_two(): + expected = ['a','b','z','c','d'] + actual = array_shift(['a','b','c','d'],'z') + assert actual == expected + +# test should pass for array with odd number of elements where elements are letters and integers +def test_three(): + expected = [1,2,3,'a',4,5] + actual = array_shift([1,2,3,4,5],'a') + assert actual == expected + + + +# Edge Case +# test should pass for initial array with only 2 elements +def test_four(): + expected = [1,2,1] + actual = array_shift([1,1],2) + assert actual == expected + + + +# Expected Failure +# test should pass for initial array with elements ptinted with spaces +def test_five(): + expected = [1,2,9,3] + actual = array_shift([ 1 , 2 , 3 ],9) + assert actual == expected + +# test should pass for initial array with only one element +def test_six(): + expected = [1,2] + actual = array_shift([1],2) + assert actual == expected + + + diff --git a/tests/data_structures/__pycache__/test_linked_list.cpython-38-pytest-6.1.2.pyc b/tests/data_structures/__pycache__/test_linked_list.cpython-38-pytest-6.1.2.pyc new file mode 100644 index 0000000..2f8526f Binary files /dev/null and b/tests/data_structures/__pycache__/test_linked_list.cpython-38-pytest-6.1.2.pyc differ