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
38
39
40
41
42
43
44
|
#!/usr/bin/env julia
#=
----------------------------------
AUTHOR: Robert DiCicco
DATE : 2023-03-07
Challenge 207 H-Index ( Julia )
----------------------------------
=#
using Printf
citations = [10,8,5,4,3],[25,8,5,3,3]
function CalcIndex(c)
ln = length(c)
offset = ln
pos = ln
while offset >= 1
if c[offset] >= pos
@printf("Output: %d\n", pos)
println(" ")
return
else
offset -= 1
pos -= 1
end
end
end
for c in citations
@printf("Input: @citations = %s\n",c)
CalcIndex(c)
end
#=
----------------------------------
SAMPLE OUTPUT
julia .\HIndex.jl
Input: @citations = [10, 8, 5, 4, 3]
Output: 4
Input: @citations = [25, 8, 5, 3, 3]
Output: 3
----------------------------------
=#
|