Created
June 14, 2016 19:45
-
-
Save tmountain/01bb6ed02cfec263c93dbf68c78703f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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