-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python/difference-of-squares: 1st iteration
- Loading branch information
Showing
15 changed files
with
612 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!coverage.py: This is a private format, don't read it directly!{"arcs":{"/home/vpayno/git_vpayno/exercism-workspace/python/difference-of-squares/test/__init__.py":[[0,0],[0,-1]],"/home/vpayno/git_vpayno/exercism-workspace/python/difference-of-squares/difference_of_squares.py":[[0,1],[1,4],[4,14],[14,24],[24,-1],[24,31],[4,11],[11,-4],[14,21],[21,-14],[31,-24]]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" ?> | ||
<coverage branch-rate="1" branches-covered="0" branches-valid="0" complexity="0" line-rate="0.8571" lines-covered="6" lines-valid="7" timestamp="1713242888288" version="4.5.4"> | ||
<!-- Generated by coverage.py: https://coverage.readthedocs.io --> | ||
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd --> | ||
<sources> | ||
<source>/home/vpayno/git_vpayno/exercism-workspace/python/difference-of-squares</source> | ||
</sources> | ||
<packages> | ||
<package branch-rate="1" complexity="0" line-rate="0.8571" name="."> | ||
<classes> | ||
<class branch-rate="1" complexity="0" filename="difference_of_squares.py" line-rate="0.8571" name="difference_of_squares.py"> | ||
<methods/> | ||
<lines> | ||
<line hits="0" number="0"/> | ||
<line hits="1" number="4"/> | ||
<line hits="1" number="11"/> | ||
<line hits="1" number="14"/> | ||
<line hits="1" number="21"/> | ||
<line hits="1" number="24"/> | ||
<line hits="1" number="31"/> | ||
</lines> | ||
</class> | ||
</classes> | ||
</package> | ||
<package branch-rate="1" complexity="0" line-rate="1" name="test"> | ||
<classes> | ||
<class branch-rate="1" complexity="0" filename="test/__init__.py" line-rate="1" name="__init__.py"> | ||
<methods/> | ||
<lines/> | ||
</class> | ||
</classes> | ||
</package> | ||
</packages> | ||
</coverage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[run] | ||
omit = __init__.py, *_test.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../.pylintrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
def square_of_sum(number): | ||
pass | ||
"""Python Difference of Squares Exercism""" | ||
|
||
|
||
def sum_of_squares(number): | ||
pass | ||
def square_of_sum(number: int) -> int: | ||
"""Calculates the square of sum. | ||
:param number: int | ||
:return: int | ||
""" | ||
|
||
def difference_of_squares(number): | ||
pass | ||
return (number * (number + 1) // 2) ** 2 | ||
|
||
|
||
def sum_of_squares(number: int) -> int: | ||
"""Calculates the sum of squares. | ||
:param number: int | ||
:return: int | ||
""" | ||
|
||
return (number * (number + 1) * (2 * number + 1)) // 6 | ||
|
||
|
||
def difference_of_squares(number: int) -> int: | ||
"""Calculates the difference of squares. | ||
:param number: int | ||
:return: int | ||
""" | ||
|
||
return square_of_sum(number) - sum_of_squares(number) |
31 changes: 31 additions & 0 deletions
31
python/difference-of-squares/difference_of_squares.py,cover
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
> """Python Difference of Squares Exercism""" | ||
|
||
|
||
> def square_of_sum(number: int) -> int: | ||
> """Calculates the square of sum. | ||
|
||
> :param number: int | ||
> :return: int | ||
> """ | ||
|
||
> return (number * (number + 1) // 2) ** 2 | ||
|
||
|
||
> def sum_of_squares(number: int) -> int: | ||
> """Calculates the sum of squares. | ||
|
||
> :param number: int | ||
> :return: int | ||
> """ | ||
|
||
> return (number * (number + 1) * (2 * number + 1)) // 6 | ||
|
||
|
||
> def difference_of_squares(number: int) -> int: | ||
> """Calculates the difference of squares. | ||
|
||
> :param number: int | ||
> :return: int | ||
> """ | ||
|
||
> return square_of_sum(number) - sum_of_squares(number) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[pytest] | ||
pythonpath = . | ||
addopts = --doctest-modules | ||
markers = | ||
task: exercise task/step |
Oops, something went wrong.