Skip to content

Instantly share code, notes, and snippets.

@faizaanshamsi
Created November 16, 2013 01:00
Show Gist options
  • Save faizaanshamsi/7494428 to your computer and use it in GitHub Desktop.
Save faizaanshamsi/7494428 to your computer and use it in GitHub Desktop.
Provides Average, Low Score, High Score for a hardcoded list of scores.
scores_raw = [75, 100, 85, 65, 84, 87, 95]
scores = scores_raw.sort
sum = scores.inject(0) { |total, x| total + x}
average = sum/(scores.length)
puts "The Average Score is #{average}"
puts "The Lowest Score is #{scores.first}"
puts "The Highest Score is #{scores.last}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment