summaryrefslogtreecommitdiff
path: root/percentile
blob: ba9ceb03be5cec12ea81ee7f47f57e071787fffe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env ruby

require 'zipf'

data = []
while line = STDIN.gets
  data << line.to_f
end

data.sort!

k = ARGV[0].to_i

index = (k / 100.0) * data.size

if index.to_i == index
  puts data[index.to_i-1]
else
  puts (data[index.to_i-1] + data[index.to_i]) / 2.0
end