Skip to content

Commit

Permalink
# You're a square
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 20, 2024
1 parent a5d9cf5 commit 25a4ce9
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 27 deletions.
6 changes: 3 additions & 3 deletions kyu_7/you_are_square/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ them into a square of square building blocks!

However, sometimes, you can't arrange them into a square. Instead,
you end up with an ordinary rectangle! Those blasted things! If you
just had a way to know, whether you're currently working in vain… Wait!
That's it! You just have to check if your number of building blocks
is a perfect square.
just had a way to know whether you're currently working in vain… Wait!
That's it! You just have to check if your `number of building blocks
is a perfect square`.

## Task

Expand Down
1 change: 1 addition & 0 deletions kyu_7/you_are_square/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""You're a square."""
53 changes: 33 additions & 20 deletions kyu_7/you_are_square/test_you_are_square.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> You\'re a square
Test for -> You\'re a square.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -26,24 +27,26 @@
# pylint: enable=R0801
class YouAreSquareTestCase(unittest.TestCase):
"""
Testing is_square function
Testing is_square function.
The tests will always use some integral number,
so don't worry about that in dynamic typed languages.
"""

def test_is_square_negative_numbers(self):
"""
-1: Negative numbers cannot be square numbers
Negative numbers cannot be square numbers.
:return:
"""
# pylint: disable=R0801
allure.dynamic.title("Negative numbers")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'<h3>Codewars badge:</h3>'
'<img src="https://www.codewars.com/users/myFirstCode'
'/badges/large">'
'<img src="'
'https://www.codewars.com/users/myFirstCode/badges/large'
'">'
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable=R0801
Expand All @@ -54,16 +57,18 @@ def test_is_square_negative_numbers(self):

def test_is_square_zero(self):
"""
0 is a square number
0 is a square number.
:return:
"""
# pylint: disable=R0801
allure.dynamic.title("Zero")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'<h3>Codewars badge:</h3>'
'<img src="https://www.codewars.com/users/myFirstCode'
'/badges/large">'
'<img src="'
'https://www.codewars.com/users/myFirstCode/badges/large'
'">'
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable=R0801
Expand All @@ -74,16 +79,18 @@ def test_is_square_zero(self):

def test_is_square_negative_test(self):
"""
3 is not a square number
3 is not a square number.
:return:
"""
# pylint: disable=R0801
allure.dynamic.title("Non square numbers (negative)")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'<h3>Codewars badge:</h3>'
'<img src="https://www.codewars.com/users/myFirstCode'
'/badges/large">'
'<img src="'
'https://www.codewars.com/users/myFirstCode/badges/large'
'">'
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable=R0801
Expand All @@ -94,16 +101,18 @@ def test_is_square_negative_test(self):

def test_is_square_four(self):
"""
4 is a square number
4 is a square number.
:return:
"""
# pylint: disable=R0801
allure.dynamic.title("Square numbers (positive)")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'<h3>Codewars badge:</h3>'
'<img src="https://www.codewars.com/users/myFirstCode'
'/badges/large">'
'<img src="'
'https://www.codewars.com/users/myFirstCode/badges/large'
'">'
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable=R0801
Expand All @@ -114,16 +123,18 @@ def test_is_square_four(self):

def test_is_square_25(self):
"""
25 is a square number
25 is a square number.
:return:
"""
# pylint: disable=R0801
allure.dynamic.title("Square numbers (positive)")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'<h3>Codewars badge:</h3>'
'<img src="https://www.codewars.com/users/myFirstCode'
'/badges/large">'
'<img src="'
'https://www.codewars.com/users/myFirstCode/badges/large'
'">'
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable=R0801
Expand All @@ -134,16 +145,18 @@ def test_is_square_25(self):

def test_is_square_26(self):
"""
26 is not a square number
26 is not a square number.
:return:
"""
# pylint: disable=R0801
allure.dynamic.title("Non square numbers (negative)")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'<h3>Codewars badge:</h3>'
'<img src="https://www.codewars.com/users/myFirstCode'
'/badges/large">'
'<img src="'
'https://www.codewars.com/users/myFirstCode/badges/large'
'">'
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable=R0801
Expand Down
10 changes: 6 additions & 4 deletions kyu_7/you_are_square/you_are_square.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
"""
Solution for -> You\'re a square
Solution for -> You\'re a square.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""

import math


def is_square(n) -> bool:
def is_square(n: int) -> bool:
"""
Given an integral number, determine if it's a square number:
Given an integral number, determine if it's a square number.
:param n:
:return:
:return: bool
"""
if n > -1:
number = math.sqrt(n)
Expand Down

0 comments on commit 25a4ce9

Please sign in to comment.