aboutsummaryrefslogtreecommitdiff
path: root/challenge-198/lubos-kolouch/python/ch-1.py
blob: 6cfd53a2eaf740b02333d0a4b48822a7e977cb82 (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
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest


def max_gap(lst):
    if len(lst) < 2:
        return 0
    lst.sort()
    max_gap = max(lst[i + 1] - lst[i] for i in range(len(lst) - 1))
    return sum(1 for i in range(len(lst) - 1)
               if lst[i + 1] - lst[i] == max_gap)


class TestMaxGap(unittest.TestCase):

    def test_cases(self):
        self.assertEqual(max_gap([2, 5, 8, 1]), 2, 'Test Case 1')
        self.assertEqual(max_gap([3]), 0, 'Test Case 2')


if __name__ == '__main__':
    unittest.main()