Skip to content

Commit

Permalink
## About this Kata
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 20, 2024
1 parent e326058 commit 32bfe3e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 38 deletions.
1 change: 1 addition & 0 deletions kyu_7/coloured_triangles/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Coloured Triangles."""
12 changes: 7 additions & 5 deletions kyu_7/coloured_triangles/solution_for_triangle.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Solution for -> Coloured Triangles
Solution for -> Coloured Triangles.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -17,14 +18,15 @@
'G': 'G',
'GG': 'G',
'BR': 'G',
'RB': 'G',
}
'RB': 'G'}


def triangle(row: str) -> str:
"""
You will be given the first row of the triangle as a string
and its your job to return the final colour which would
Triangle function.
You will be given the first row of the triangle as a string,
and it's your job to return the final colour which would
appear in the bottom row as a string. I
:param row: str, the first row of the triangle as a string
Expand Down
64 changes: 31 additions & 33 deletions kyu_7/coloured_triangles/test_triangle.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> Coloured Triangles
Test for -> Coloured Triangles.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -8,6 +9,7 @@

import unittest
import allure # pylint: disable=import-error
from parameterized import parameterized
from utils.log_func import print_log
from kyu_7.coloured_triangles.solution_for_triangle import triangle

Expand All @@ -27,39 +29,35 @@
name='Source/Kata')
# pylint: enable-msg=R0801
class TriangleTestCase(unittest.TestCase):
"""
Testing triangle function
"""
"""Testing triangle function."""

def test_triangle(self):
@parameterized.expand([
('GB', 'R'),
('RRR', 'R'),
('RGBG', 'B'),
('RBRGBRB', 'G'),
('RBRGBRBGGRRRBGBBBGG', 'G'),
('B', 'B'),
('BGBGB', 'R'),
('BBRRBRGBRRBRGRRBGGRRBBGBGGRGGB', 'G'),
('RB', 'G'),
('GRBGRGBBRBRGRRGGGGRBRBRGGRB', 'B'),
('BBGRBGRRGGGRRBRBRBGRBGRRRBBBG', 'G'),
('RRBBRRGBRBGBRBRGBGGRBBBBRGGRGB', 'R'),
('GGBRGBBRBGRRGGGBGBGRGBGGRGRB', 'R'),
('BRBBGGRGBGGGBGRBRGRGRRBBGBR', 'G'),
('GBBRBRGGGGBRGGBBGGBGBRGRBGRGBB', 'G'),
('RRRBRRGRRGBGBBRGRGRGRB', 'B'),
('BRGGRBBBBGBRRRRBRBRRBGBGRBGB', 'B'),
('RRBRBRBBBBBRBRRBBBGBBGBGGGRGR', 'G')])
def test_triangle(self, string, expected):
"""
Basic test case
Basic test case.
:return:
"""
with allure.step("Enter test string and verify the output"):
test_data = [
('GB', 'R'),
('RRR', 'R'),
('RGBG', 'B'),
('RBRGBRB', 'G'),
('RBRGBRBGGRRRBGBBBGG', 'G'),
('B', 'B'),
('BGBGB', 'R'),
('BBRRBRGBRRBRGRRBGGRRBBGBGGRGGB', 'G'),
('RB', 'G'),
('GRBGRGBBRBRGRRGGGGRBRBRGGRB', 'B'),
('BBGRBGRRGGGRRBRBRBGRBGRRRBBBG', 'G'),
('RRBBRRGBRBGBRBRGBGGRBBBBRGGRGB', 'R'),
('GGBRGBBRBGRRGGGBGBGRGBGGRGRB', 'R'),
('BRBBGGRGBGGGBGRBRGRGRRBBGBR', 'G'),
('GBBRBRGGGGBRGGBBGGBGBRGRBGRGBB', 'G'),
('RRRBRRGRRGBGBBRGRGRGRB', 'B'),
('BRGGRBBBBGBRRRRBRBRRBGBGRBGB', 'B'),
('RRBRBRBBBBBRBRRBBBGBBGBGGGRGR', 'G')]

for string, expected in test_data:
result = triangle(string)
print_log(string=string,
expected=expected,
result=result)
self.assertEqual(expected, result)
with allure.step(f"Enter test string: {string} "
f"and verify the output: {expected}"):
result = triangle(string)
print_log(string=string, expected=expected, result=result)
self.assertEqual(expected, result)

0 comments on commit 32bfe3e

Please sign in to comment.