A list of nonnegative integers.
The largest nonnegative integer
h such that at least
h of the numbers in the list are greater than or equal to
[0,0,0,0] -> 0 [12,312,33,12] -> 4 [1,2,3,4,5,6,7] -> 4 [22,33,1,2,4] -> 3 [1000,2,2,2] -> 2 [23,42,12,92,39,46,23,56,31,12,43,23,54,23,56,73,35,73,42,12,10,15,35,23,12,42] -> 20
You can write either a full program or a function, and anonymous functions are allowed too. This is code-golf, so the fewest byte count wins. Standard loopholes are disallowed.
The h-index is a notion used in academia which aims to capture the impact and productivity of a researcher. According to Wikipedia, a researcher has index h, if he or she has published h scientific articles, each of which has been cited in other articles at least h times. Thus, this challenge is about computing the h-index from a list of citation counts.
Wow, great answers all round! I have accepted the shortest one, but if someone else comes up with an even shorter one, I'll update my choice accordingly.
Winners by language
Here's a table of winners by language that I'll also try to keep up to date. I have included all posts with nonnegative score. Please correct me if I have made a mistake here.
- APL: 7 bytes by @MorisZucca
- Bash + coreutils: 29 bytes by @DigitalTrauma
- C#: 103 bytes by @LegionMammal978
- C++: 219 bytes by @user9587
- CJam: 15 bytes by @nutki
- GolfScript: 13 bytes by @IlmariKaronen
- Haskell: 40 bytes by @proudhaskeller
- J: 12 bytes by @ɐɔıʇǝɥʇuʎs
- Java: 107 bytes by @Ypnypn
- Mathematica: 38 bytes by @kukac67
- Perl: 32 bytes by @nutki
- Pyth: 10 bytes by @isaacg
- Python: 49 bytes by @feersum
- R: 29 bytes by @MickyT
- Ruby: 41 bytes by @daniero
- Scala: 62 bytes by @ChadRetz
- SQL: 83 bytes by @MickyT
- TI-BASIC: 22 bytes by @Timtech