SHARE
TWEET

Untitled

a guest Jun 20th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. arr = [7600, 5900, 1400]
  2. seats = 36
  3.  
  4. total = 0.0
  5.  
  6. arr.each { |e| total += e }
  7.  
  8. puts "Total: #{total}"
  9.  
  10. s_d = total / seats
  11.  
  12. puts "SD: #{s_d}"
  13. puts
  14.  
  15. puts "State\tPopulation\tQ\tLQ\tApportionment"
  16.  
  17. arr.each do |v|
  18.   s_q = v / s_d
  19.  
  20.   puts "#{arr.index(v)}\t#{v}\t#{s_q.truncate(3)}\t#{s_q.truncate}"
  21. end
  22.  
  23. l_q_total = 0
  24.  
  25. arr.each { |e| l_q_total += (e / s_d).truncate}
  26.  
  27. puts "Total\t#{total}\t#{seats}\t#{l_q_total}"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top