Skip to content

Instantly share code, notes, and snippets.

@masarakki
Created September 21, 2012 12:31
Show Gist options
  • Save masarakki/3761216 to your computer and use it in GitHub Desktop.
Save masarakki/3761216 to your computer and use it in GitHub Desktop.
aabbcc
str = "aabbcc"
str.chars.to_a.permutation(str.size).select{|x| 1.upto(x.size).all? { |i| x[i] != x[i-1] } }.uniq.count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment