aboutsummaryrefslogtreecommitdiff
path: root/challenge-207/robert-dicicco/python/ch-2.py
blob: 4327ca5d04cfd27d995a18914cd3cce9b4ee3129 (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
37
#!/usr/bin/env python
'''
----------------------------------
AUTHOR: Robert DiCicco
DATE  : 2023-03-07
Challenge 207 H-Index ( Python )
==================================
'''
citations = [10,8,5,4,3],[25,8,5,3,3]

def CalcIndex(c):
    ln = len(c)
    offset = ln - 1
    pos = ln
    while offset >= 0 :
        if c[offset] >= pos :
            print("Output: ",pos,"\n")
            return
        else :
            offset -= 1
            pos -= 1

for c in citations:
    print("Input: @citations =",c)
    CalcIndex(c)

'''
----------------------------------
SAMPLE OUTPUT
python .\HIndex.py
Input: @citations = [10, 8, 5, 4, 3]
Output:  4

Input: @citations = [25, 8, 5, 3, 3]
Output:  3
----------------------------------
'''