Ad
  • Default User Avatar

    I also confused because of below description result.
    I understood that if there are same combination of two values, should return combination that distance between two values is shortest.

    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]
    

    If that, what is the below case's expected answer?

    sum_pairs([10, 5, 2, 5, 3, 7, 5],         10)
    

    Through my understanding, the expected combination is '[3, 7]'.
    If I was wrong, I am sorry confusing everyone.

    sum_pairs([10, 5, 2, 5, 3, 7, 5],         10)
                   ^-----^          5 + 5 = 10, indices: 1, 3
                            ^--^    3 + 7 = 10, indices: 4, 5 *
    
    
  • Default User Avatar

    The one requirement is absent.
    'the definition of valid spacing is one space between words'