Last active
December 11, 2015 11:48
-
-
Save koffeinfrei/4596183 to your computer and use it in GitHub Desktop.
3 char combinations (of my name)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# try pairs of 2 | |
def pairs_of_2(names) | |
slices = names.join.scan(/.{2}/) | |
combinations(slices) | |
end | |
# try each chars | |
def pairs_of_chars(names) | |
chars = names.join.chars.to_a.uniq | |
combinations(combinations(chars)) | |
end | |
def combinations(slices) | |
slices.product(slices).map {|x| x.join[0..2]}.uniq | |
end | |
names = %w(alexis reigel) | |
#puts pairs_of_2 names | |
puts pairs_of_chars names |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment