Skip to content

Instantly share code, notes, and snippets.

@plindberg
Created March 25, 2014 13:17
Show Gist options
  • Save plindberg/9761609 to your computer and use it in GitHub Desktop.
Save plindberg/9761609 to your computer and use it in GitHub Desktop.
Count occurrences of S, M, L, X in a string
`pbpaste`.split(',').sort_by{|x|'SMLX'.index(x)}.inject({}){|h,x|h[x]=(h[x]||0)+1;h}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment