Created
May 18, 2014 20:05
-
-
Save amckinley/1cd5fa69a9d42e057760 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 find_min_and_max(values): | |
max_val = 0 | |
min_val = 0 | |
i = 0 | |
while i < len(values): | |
c = values[i] | |
if c == '-': | |
val = int(values[i:i+2]) | |
i += 2 | |
else: | |
val = int(c) | |
i += 1 | |
if val > max_val: | |
max_val = val | |
if val < min_val: | |
min_val = val | |
return max_val, min_val | |
if __name__ == "__main__": | |
print find_min_and_max("1-254-4-6") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment