aboutsummaryrefslogtreecommitdiff
path: root/challenge-207/sgreen/python/ch-2.py
blob: e76b64c03f54220141a23067fa25b21a27a41595 (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 python3

import sys


def main(n):
    h_index = 0

    for i in range(1, len(n)+1):
        # Count the number of items that are >= i
        count = sum(1 for x in n if x >= i)
        if count >= i:
            h_index = i
        else:
            # No point trying any more, as it will be False.
            break

    print(h_index)


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