Skip to content

Instantly share code, notes, and snippets.

View bcjordan's full-sized avatar

Brian Jordan bcjordan

View GitHub Profile
@bcjordan
bcjordan / parse_brackets.rb
Created January 18, 2011 02:43
parsing / combination exercise
# 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