Skip to content

Instantly share code, notes, and snippets.

@dmehrotra
Created August 28, 2013 14:33
Show Gist options
  • Select an option

  • Save dmehrotra/6366675 to your computer and use it in GitHub Desktop.

Select an option

Save dmehrotra/6366675 to your computer and use it in GitHub Desktop.
kata
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