-
-
Save dmehrotra/6366675 to your computer and use it in GitHub Desktop.
kata
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
| require 'csv' | |
| failures=[] | |
| lows=[] | |
| mids=[] | |
| highs=[] | |
| CSV.foreach('test.csv', headers: true) do |row| | |
| score = row[1].to_f | |
| if score < 70 | |
| fails = {} | |
| fails[row[0]] = row[1] | |
| failures << fails | |
| elsif score > 70 && score <= 80 | |
| low = {} | |
| low[row[0]] = row[1] | |
| lows << low | |
| elsif score > 80 && score <=90 | |
| mid = {} | |
| mid[row[0]] = row[1] | |
| mids << mid | |
| elsif score > 90 | |
| high = {} | |
| high[row[0]] = row[1] | |
| highs << high | |
| end | |
| end | |
| puts "90 +: #{highs.length}" | |
| puts "80 +: #{mids.length}" | |
| puts "70 +: #{lows.length}" | |
| puts "60 -: #{failures.length}" | |
| puts "========HIGHS=========" | |
| puts highs.each{|key, value| key} | |
| puts "========Mediums=========" | |
| puts mids.each{|key, value| key} | |
| puts "========Lows=========" | |
| puts lows.each{|key, value| key} | |
| puts "========FAILS=========" | |
| puts failures.each{|key, value| key} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment