Created
November 22, 2017 15:26
-
-
Save marceloandriolli/d69f12e55af0cb644e7c4f4dcf696640 to your computer and use it in GitHub Desktop.
Coding Dojo - Stormtech - 22 de Novembro
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
# The number 6 is a truly great number. Given two int values, a and b, | |
# return True if either one is 6. Or if their sum or difference is 6. | |
# Note: the function abs(num) computes the absolute value of a number. | |
# love6(6, 4) → True | |
# love6(4, 5) → False | |
# love6(1, 5) → True | |
# love6(7,1) | |
def love6(a, b): | |
if 6 in (a, b): | |
return True | |
return a+b == 6 or abs(a-b) - 6 == 0 or abs(b-a) - 6 == 0 | |
assert love6(6, 4) | |
assert love6(4, 6) | |
assert love6(4, 5) is False | |
assert love6(1, 5) | |
assert love6(-1, 7) | |
assert love6(1, 7) | |
assert love6(-3, -3) is False | |
assert love6(3, -3) | |
assert love6(-3, 3) | |
assert love6(0, 0) is False | |
assert love6(0, -6) | |
assert love6(-6, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment