-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Difference of squares: sync expected test results and input data with problem-specifications #1791
Merged
cmccandless
merged 6 commits into
exercism:master
from
BethanyG:difference-of-squares-changes
May 31, 2019
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7eda3ed
difference-of-squares: sync expected test results and input data with…
BethanyG c26d7c2
Changed argument name to number from count.
BethanyG 0a6a2fa
Merge branch 'master' into difference-of-squares-changes
BethanyG b48a8b4
difference of squares: formatted import statements in tests to meet c…
BethanyG 3ebfb01
Update exercises/difference-of-squares/example.py
BethanyG 0f5b593
Merge branch 'master' into difference-of-squares-changes
cmccandless File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(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 | ||
BethanyG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
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) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is preferable to use parenthesis instead of backslashes for multiline imports. Example:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops. I did not see this, or I wouldn't have closed this and deleted the branch. I am an idiot. :P Will re-open and correct!