aboutsummaryrefslogtreecommitdiff
path: root/challenge-198/sgreen/python/ch-1.py
blob: c1981be24c76f1b761caa6de4cec6ac9a250735f (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
#!/usr/bin/env python3

import sys


def main(n):
    gap = 0     # The maximum gap
    count = 0   # Number of occurrences

    # Sort the list
    n = sorted(n)

    # Iterate through the list
    for i in range(len(n)-1):
        diff = n[i+1] - n[i]
        if diff > gap:
            # We have a new maximum, reset the count
            gap = diff
            count = 1
        elif diff == gap:
            # Add to the count
            count += 1

    # Display the result
    print(count)


if __name__ == '__main__':
    # Turn the strings into integers
    n = [int(i) for i in sys.argv[1:]]
    main(n)