Skip to content

Instantly share code, notes, and snippets.

@zloyrusskiy
Created October 8, 2015 20:07
Show Gist options
  • Save zloyrusskiy/36f2e7cadea546cfa71e to your computer and use it in GitHub Desktop.
Save zloyrusskiy/36f2e7cadea546cfa71e to your computer and use it in GitHub Desktop.
def more_than_medium string
words = string.split /\W+/
return [] if words.empty?
avg = words.inject(0) { |res, w| res += w.size; res } / words.size
words.select { |w| w.size > avg }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment