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
# Run using rspec parse_brackets.rb | |
# Uses array combination/permutation method from | |
# http://trevoke.net/blog/2009/12/17/inter-array-permutations-in-ruby/ | |
# Takes an array of arrays and returns permutations of them | |
# e.g., fancy_array_permutation[["one", "two"], ["three", "four"]] | |
# returns: ["onethree", "onefour", "twothree", "twofour"] | |
def fancy_array_permutation array | |
return array[0] if array.size == 1 |
NewerOlder