Ad
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • 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

    This should not be the solution. Out of sheer luck, this worked.

  • 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.

  • Custom User Avatar

    First Match From Left REDUX!: [10, 5, 2, 3, 7, 5] should return [3, 7] for sum = 10

    Wrong test case, it should return [5,5] because their indices (1,5) are lower than (3,4)