Ad
  • Default User Avatar

    sum_pairs([10, 5, 2, 3, 7, 5], 10) should return [5, 5] and NOT [5, 5] according to the given instructions of left REDUX.
    Can this ambiguity be taken care of please?

  • Custom User Avatar

    Just as bkaes said, the goal is to return the pair of indices where the second index is the smallest.

    To more easily imagine the scenario, if it were possible to solve this problem in a single left-to-right pass, then it would make sense that the pair to be returned would be the first "complete" pair encountered. Any numbers after the second index of the pair would not even be visited.

  • Custom User Avatar

    To quote the description:

    sum_pairs([10, 5, 2, 3, 7, 5],         10)
    
    #              ^-----------^   5 + 5 = 10, indices: 1, 5
    #                    ^--^      3 + 7 = 10, indices: 3, 4 *
    #  * entire pair is earlier, and therefore is the correct answer
    == [3, 7]
    

    Even though the description could include a little bit more text to make this more clear, the kata actually expects you to find the pair with the smaller second index.