Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- # encoding: utf-8
- require 'time'
- WINDOW=3600
- events=Hash.new{|h,k| h[k]=[]}
- max=Hash.new(0)
- maxpos=Hash.new(0)
- File.open('lista.txt','r').each do |line|
- ts,ev=line.split
- events[ev].push(ts.to_i)
- end
- events.each do |ev,aots|
- aots.each do |ts|
- evc=aots.select{|x| x>=ts && x<=ts+WINDOW}.count
- max[ev],maxpos[ev]=evc,ts if evc>max[ev]
- end
- end
- max.each_key do |ev|
- printf "%-20s %4d %s\n",ev,max[ev],Time.at(maxpos[ev]).strftime('%b %d %H:%M:%S')
- end
Advertisement
Add Comment
Please, Sign In to add comment