Skip to content

Instantly share code, notes, and snippets.

@townie
Created February 21, 2014 23:23
Show Gist options
  • Save townie/9145748 to your computer and use it in GitHub Desktop.
Save townie/9145748 to your computer and use it in GitHub Desktop.
I love 1 liners
cuz_i_am_lazy= %w(75
100
85
65
84
87
95)
score= cuz_i_am_lazy.map{ |x| x.to_i}
puts score.inject(){|sum, value| sum + value} / score.length
puts score.minmax_by { |x| x}
@faizaanshamsi
Copy link

your score variable is an array, I'd call it scores so it's more expressive.

@faizaanshamsi
Copy link

Otherwise, great job!

@townie
Copy link
Author

townie commented Feb 24, 2014

Thanks man! I really appreciate it

@faizaanshamsi
Copy link

Also, use .to_f instead of to_i, it's more accurate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment