-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Difference of squares: sync expected test results and input data with…
… problem-specifications (#1791)
- Loading branch information
1 parent
a35bab9
commit 140f012
Showing
3 changed files
with
18 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
def square_of_sum(count): | ||
def square_of_sum(number): | ||
pass | ||
|
||
|
||
def sum_of_squares(count): | ||
def sum_of_squares(number): | ||
pass | ||
|
||
|
||
def difference(count): | ||
def difference_of_squares(number): | ||
pass |
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,11 +1,12 @@ | ||
def square_of_sum(count): | ||
sum_ = count * (count + 1) / 2 | ||
def square_of_sum(number): | ||
sum_ = number * (number + 1) / 2 | ||
return sum_ * sum_ | ||
|
||
|
||
def sum_of_squares(count): | ||
return sum(m * m for m in range(count + 1)) | ||
def sum_of_squares(number): | ||
numerator = number * (number + 1) * (2 * number + 1) | ||
return numerator / 6 | ||
|
||
|
||
def difference(count): | ||
return square_of_sum(count) - sum_of_squares(count) | ||
def difference_of_squares(number): | ||
return square_of_sum(number) - sum_of_squares(number) |