Skip to content

Instantly share code, notes, and snippets.

@JEG2
Created February 6, 2012 18:59
Show Gist options
  • Select an option

  • Save JEG2/1754081 to your computer and use it in GitHub Desktop.

Select an option

Save JEG2/1754081 to your computer and use it in GitHub Desktop.
s = "james"
subs = (1..s.size).inject([ ]) { |a, l| a.push(*s.split("").each_cons(l)) }
p subs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment