Skip to content

Commit

Permalink
# Pyramid Array
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 17, 2024
1 parent 33c7994 commit 1d08d44
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions kyu_6/pyramid_array/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Pyramid Array."""
5 changes: 4 additions & 1 deletion kyu_6/pyramid_array/pyramid_array.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""
Solution for -> Pyramid Array
Solution for -> Pyramid Array.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def pyramid(n: int) -> list:
"""
Pyramid function.
Write a function that when given a number >= 0,
returns an Array of ascending length subarrays.
Expand Down
22 changes: 12 additions & 10 deletions kyu_6/pyramid_array/test_pyramid_array.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> Pyramid Array
Test for -> Pyramid Array.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -25,15 +26,16 @@
name='Source/Kata')
# pylint: enable-msg=R0801
class PyramidTestCase(unittest.TestCase):
"""
Testing 'pyramid' function
"""
"""Testing 'pyramid' function."""

def test_pyramid(self):
"""
Testing 'pyramid' function with various test data.
The 'pyramid' function should return
an Array of ascending length subarrays.
an Array of ascending length sub-arrays.
Note: the subarrays should be filled with 1s.
Note: the sub-arrays should be filled with 1s.
:return:
"""
# pylint: disable-msg=R0801
Expand All @@ -46,25 +48,25 @@ def test_pyramid(self):
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable-msg=R0801
with allure.step("Pass zero"):
with allure.step("Pass zero:"):
n: int = 0
expected: list = []
print_log(n=n, expected=expected)
self.assertEqual(pyramid(n), expected)

with allure.step("Pass one"):
with allure.step("Pass one:"):
n = 1
expected = [[1]]
print_log(n=n, expected=expected)
self.assertEqual(pyramid(n), expected)

with allure.step("Pass two"):
with allure.step("Pass two:"):
n = 2
expected = [[1], [1, 1]]
print_log(n=n, expected=expected)
self.assertEqual(pyramid(n), expected)

with allure.step("Pass three"):
with allure.step("Pass three:"):
n = 3
expected = [[1], [1, 1], [1, 1, 1]]
print_log(n=n, expected=expected)
Expand Down

0 comments on commit 1d08d44

Please sign in to comment.