This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
DSA/midterm_prep/202_max_distance.py

27 lines
416 B
Python
Raw Normal View History

2019-03-28 10:45:47 +00:00
#!/usr/bin/env python3
import sys
def maximal_distance(A):
if len(A) == 0:
return None
max_n = A[0]
min_n = A[0]
for i in range(1,len(A)):
if max_n < A[i]:
max_n = A[i]
elif min_n > A[i]:
min_n = A[i]
return max_n - min_n
A = []
for line in sys.stdin:
if line[0] == '\n':
break
A.append(int(line))
print(maximal_distance(A))