• return the first two values (parse from the left please) in order of appearance that add up to form the sum.

    The first pair is clearly [1, 3] and this solution will return that value. So no issue.

  • Maybe use something different than a nested for loop to look if some value already was present. Something with a faster lookup.

  • Very unclear description. Anybody can explain what should be done with p = [ 0, 1, 5, 8, 9, 10] ?

  • nice kata!

  • Yes, and your code is returning [2, 0] instead. Not a kata issue.

  • Seems this kata is broken:

    [1, 2, 3, 4, 1, 0] should return [1, 1] for sum = 2: expected [ 2, 0 ] to deeply equal [ 1, 1 ]

    But answer should be [1, 1], isn't it?

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

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

  • OP solved it, closing

  • Very good task!
    Advice for people who couldn't optimize: try to pay attention for relation between right and left index and try to use it in your loop

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

  • Very questionable use of the phrase "entire pair is earlier". Entire pair is NOT earlier in your example. In the first pair, the first element is earlier, in the second - second is earlier. It seems that the description is matched to the algorithm.

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

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

  • Element with higher position decides of position of pair.
    For example:
    for sum = 6 in [1, 3, 0, 4, 6, 3, 8] there are two pairs: 3, 3 (at pos. 1, 5) and 0, 6 (at 2, 4). (3,3) is at 5 and (0, 6) is at 4. So "entire pair (0, 6) is earlier".

  • Loading more items...