Skip to content

Commit

Permalink
# Casino chips
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 17, 2024
1 parent 8d735fd commit 878727b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 36 deletions.
1 change: 1 addition & 0 deletions kyu_6/casino_chips/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Casino chips."""
6 changes: 4 additions & 2 deletions kyu_6/casino_chips/solve.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""
Solution for Casino chips
Solution for Casino chips.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def solve(arr: list) -> int:
"""
Solve function.
You are given three piles of casino chips: white, green and black
chips:
Expand All @@ -26,7 +29,6 @@ def solve(arr: list) -> int:
:return:
"""
arr = sorted(arr)

if arr[0] + arr[1] <= arr[2]:
return arr[0] + arr[1]

Expand Down
62 changes: 28 additions & 34 deletions kyu_6/casino_chips/test_solve.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for Casino chips
Test for Casino chips.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -8,6 +9,7 @@

import unittest
import allure
from parameterized import parameterized
from kyu_6.casino_chips.solve import solve
from utils.log_func import print_log

Expand All @@ -28,12 +30,26 @@
name='Source/Kata')
# pylint: enable-msg=R0801
class SolveTestCase(unittest.TestCase):
"""
Testing solve function
"""
def test_solve(self):
"""Testing solve function."""

@parameterized.expand([
([8, 8, 8], 12),
([1, 1, 1], 1),
([8, 1, 4], 5),
([7, 4, 10], 10),
([12, 12, 12], 18),
([6, 6, 6], 9),
([1, 23, 2], 3),
([9, 8, 6], 11),
([10, 9, 6], 12),
([4, 4, 3], 5),
([1, 2, 1], 2),
([4, 1, 1], 2),
([8, 2, 8], 9)])
def test_solve(self, arr, expected):
"""
Testing 'solve' function with various test data
Testing 'solve' function with various test data.
:return:
"""
# pylint: disable-msg=R0801
Expand All @@ -49,31 +65,9 @@ def test_solve(self):
"maximum number of days you can pick the chips. Each "
"day you need to take exactly two chips.</p>")
# pylint: enable-msg=R0801
test_data: tuple = (
([8, 8, 8], 12),
([1, 1, 1], 1),
([8, 1, 4], 5),
([7, 4, 10], 10),
([12, 12, 12], 18),
([6, 6, 6], 9),
([1, 23, 2], 3),
([9, 8, 6], 11),
([10, 9, 6], 12),
([4, 4, 3], 5),
([1, 2, 1], 2),
([4, 1, 1], 2),
([8, 2, 8], 9))

for arr, expected in test_data:
actual_result = solve(arr)

with allure.step(f"Enter an array ({arr}) and verify the "
f"expected output ({expected}) vs "
f"actual result ({actual_result})"):

print_log(arr=arr,
expected=expected,
result=actual_result)

self.assertEqual(expected,
actual_result)
actual_result = solve(arr)
with allure.step(f"Enter an array ({arr}) and verify the "
f"expected output ({expected}) vs "
f"actual result ({actual_result})"):
print_log(arr=arr, expected=expected, result=actual_result)
self.assertEqual(expected, actual_result)

0 comments on commit 878727b

Please sign in to comment.