Skip to content

Instantly share code, notes, and snippets.

@tmountain
Created June 14, 2016 19:45
Show Gist options
  • Save tmountain/01bb6ed02cfec263c93dbf68c78703f5 to your computer and use it in GitHub Desktop.
Save tmountain/01bb6ed02cfec263c93dbf68c78703f5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
fh = File.new('rules3.csv', 'r')
ranges = []
range_counts = {}
while row = fh.gets
row.chomp!
company_id, rule_count = row.split(',')
rule_count = rule_count.to_i
range_top = ((rule_count + 99) / 100) * 100
if !range_counts.has_key?(range_top)
ranges << range_top
end
range_counts[range_top] ||= 0
range_counts[range_top] += 1
end
ranges.each do |range_top|
range_bottom = range_top - 100
puts "#{range_bottom} - #{range_top}: #{range_counts[range_top]} customers"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment