4 ms·
So far, the approximate average age for a founder based on the responses is (27.8) -- require 'hpricot' sum = 0 count = 0.0 file = Hpricot(File.open("comme
by azsromej 20y ago
So far, the approximate average age for a founder based on the responses is (27.8)
--
require 'hpricot'
sum = 0
count = 0.0
file = Hpricot(File.open("comments.htm","r"))
file.search("span.comment/font") do |line|
if line.inner_html =~ /([^\s][0-9]+[.,\s])/
number = $1.strip.to_i
if number gt 10 && number lt 70
sum += number
count += 1
end
end
end
puts "average age of founder is: " + sprintf("%.1f",sum/count)