From 03e6a6514dfd975f77883e56ca2e2dc0ed56ffa6 Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 29 Mar 2021 19:55:12 +0200 Subject: Python solution for week 106, part 1 --- challenge-106/abigail/python/ch-1.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 challenge-106/abigail/python/ch-1.py (limited to 'challenge-106/abigail/python') diff --git a/challenge-106/abigail/python/ch-1.py b/challenge-106/abigail/python/ch-1.py new file mode 100644 index 0000000000..dbade40e72 --- /dev/null +++ b/challenge-106/abigail/python/ch-1.py @@ -0,0 +1,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) -- cgit