Skip to content

Instantly share code, notes, and snippets.

@amckinley
Created May 18, 2014 20:05
Show Gist options
  • Save amckinley/1cd5fa69a9d42e057760 to your computer and use it in GitHub Desktop.
Save amckinley/1cd5fa69a9d42e057760 to your computer and use it in GitHub Desktop.
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