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
You could simply compare the arrays as strings:
correct_combination = [1, 2, 3, 4, 5] yep = [8, 10, 1, 2, 3, 4, 5, 9] nope = [1, 5, 8, 2, 3, 4, 5] if yep.to_s.include?(correct_combination.to_s) puts "yep" end if nope.to_s.include?(correct_combination.to_s) puts "nope" end