blob: dbade40e723d6bef25b3610f59827f1cd83b18bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/opt/local/bin/python
#
# See ../README.md
#
#
# Run as: python ch-1.py < input-file
#
import fileinput
for line in fileinput . input ():
#
# Extract the numbers from the line of input, by splitting
# the input on white space, and forcing the chucks to be integer.
#
N = list (map (lambda x: int (x), line . split ()))
#
# sort () modifies the array
#
N . sort ()
#
# Find the maximum difference
#
max = 0
for i in range (1, len (N)):
if N [i] - N [i - 1] > max:
max = N [i] - N [i - 1]
#
# Print it
#
print (max)
|