Skip to content

Commit

Permalink
Tic-Tac-Toe Checker
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 13, 2024
1 parent 0123415 commit aa8ad7a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions kyu_5/tic_tac_toe_checker/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tic-Tac-Toe Checker."""
15 changes: 10 additions & 5 deletions kyu_5/tic_tac_toe_checker/checker.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
"""
Solution for -> Tic-Tac-Toe Checker
Solution for -> Tic-Tac-Toe Checker.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def is_solved(board) -> int:
"""
is_solved function.
Checks whether the board's current state is solved:
-1 if the board is not yet finished (there are empty spots),
1 if "X" won,
2 if "O" won,
0 if it's a cat's game (i.e. a draw).
:param board: list
:return: -1, 0, 1, or 2
"""
Expand All @@ -37,7 +39,8 @@ def is_solved(board) -> int:

def check_diagonals(board) -> int | None:
"""
Check board by diagonal
Check board by diagonal.
:param board: list
:return: 1, 2, or None
"""
Expand All @@ -64,7 +67,8 @@ def check_diagonals(board) -> int | None:

def check_cols(board) -> int | None:
"""
Check board by column
Check board by column.
:param board: list
:return: 1, 2, or None
"""
Expand All @@ -81,7 +85,8 @@ def check_cols(board) -> int | None:

def check_rows(board: list) -> int | None:
"""
Check board by row
Check board by row.
:param board: list
:return: 1, 2, or None
"""
Expand Down
10 changes: 5 additions & 5 deletions kyu_5/tic_tac_toe_checker/test_checker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Testing is_solved function
Testing is_solved function.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -24,13 +25,11 @@
url='https://www.codewars.com/kata/525caa5c1bf619d28c000335',
name='Source/Kata')
class IsSolvedTestCase(unittest.TestCase):
"""
Testing is_solved function
"""
"""Testing is_solved function."""

def test_is_solved(self):
"""
Testing is_solved function
Testing is_solved function with various test data.
The function should return whether the
board's current state is solved.
Expand All @@ -41,6 +40,7 @@ def test_is_solved(self):
1 if "X" won,
2 if "O" won,
0 if it's a cat's game (i.e. a draw).
:return:
"""
# pylint: disable-msg=R0801
allure.dynamic.title("Testing done_or_not function")
Expand Down

0 comments on commit aa8ad7a

Please sign in to comment.