Created
September 28, 2016 15:03
-
-
Save CleverProgrammer/c9534970a9691bd87463b9820ed511f0 to your computer and use it in GitHub Desktop.
Sort 3 integers in order and print them out using only 3 if statements at most.
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
def print_in_order(a, b, c): | |
if a >= b: | |
if b >= c: | |
print(c, b, a) | |
elif a >= c: | |
print(b, c, a) | |
else: | |
print(b, a, c) | |
else: | |
if a >= c: | |
print(c, a, b) | |
elif c >= b: | |
print(a, b, c) | |
else: | |
print(b, c, a) | |
print_in_order(3, 2, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment