In ruby, how do I test that one array not only has the elements of another array, but contain them in that particular order?
correct_combination = [1, 2, 3, 4, 5
I think it can be done simply.
class Array def contain? other; (self & other) == other end end correct_combination = [1, 2, 3, 4, 5] [1, 5, 8, 2, 3, 4, 5].contain?(correct_combination) # => false [8, 10, 1, 2, 3, 4, 5, 9].contain?(correct_combination) # => true