-
-
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.
Grains : sync expected test results and input data with problem-speci…
…fications (#1794) * grains: sync expected test results and input data with problem-specifications.
- Loading branch information
Showing
3 changed files
with
29 additions
and
33 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,20 +1,19 @@ | ||
def on_square(square): | ||
check_square_input(square) | ||
return 2 ** (square - 1) | ||
def square(number): | ||
check_square_input(number) | ||
|
||
return 2 ** (number - 1) | ||
|
||
def total_after(square): | ||
check_square_input(square) | ||
return sum( | ||
on_square(n + 1) for n | ||
in range(square) | ||
) | ||
|
||
def total(number): | ||
check_square_input(number) | ||
|
||
def check_square_input(square): | ||
if square == 0: | ||
return sum(square(n + 1) for n in range(number)) | ||
|
||
|
||
def check_square_input(number): | ||
if number == 0: | ||
raise ValueError("Square input of zero is invalid.") | ||
elif square < 0: | ||
elif number < 0: | ||
raise ValueError("Negative square input is invalid.") | ||
elif square > 64: | ||
elif number > 64: | ||
raise ValueError("Square input greater than 64 is invalid.") |
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,6 +1,6 @@ | ||
def on_square(integer_number): | ||
def square(number): | ||
pass | ||
|
||
|
||
def total_after(integer_number): | ||
def total(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