Skip to content

Instantly share code, notes, and snippets.

@steshaw
Created March 18, 2010 09:50
Show Gist options
  • Save steshaw/336230 to your computer and use it in GitHub Desktop.
Save steshaw/336230 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
seconds = [
2 * 60 + 58.65,
3 * 60 + 19.55,
3 * 60 + 13.48 ,
3 * 60 + 3.89,
3 * 60 + 18.69,
2 * 60 + 59.03,
2 * 60 + 58.42,
3 * 60 + 1.32,
3 * 60 + 6.54,
3 * 60 + 33.45,
3 * 60 + 16.96,
3 * 60 + 30.36,
4 * 60 + 41.44
]
sum = seconds.reduce { |acc, n| acc + n } / 60.0
#sum = seconds.reduce {:+} / 60.0 # coming in 1.9
puts "total = #{sum} minutes"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment