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

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

  • You should not return the pair with the shortest distance. You shoould return the pair which has its both elements coming before any other complete pair.
    You need to return 5, 5 because this pair's last element is at position 3, so this pair is seen as complete before reaching elements on positions 4 and 5.

  • 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 *
    
    
  • Not a kata issue, it's been explained more than once, read the posts below, please. It's also the last example in the instructions.

  • The Elixir challenge is bugging me, really.
    It expects that sum_pairs([10, 5, 2, 3, 7, 5], 10) will return {3, 7}, but I really can't see why it wouldn't return {5, 5},
    since if you check from the left, you'll find the tuple {5, 5} before. I mean, the insctructions clearly asked to search from the left.
    This is the only test that my (very not optmized) solution is failing and I don't think the test is actually well written.

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

  • If it timed out it didn't pass all test cases ecksdee

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

  • Fewer lines != more speed Sometimes more lines perform better.

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

  • This algorithm has exponential Big-O complexity. The ints.indexOf call is the same as having another for loop inside your first loop-which makes the runtime explode.

    There may be more efficient methods to solving this problem that don't require nested loops or revisiting the same elements more than once...

  • No.

    10                   // no pair
    10, 5                // no pair adding to 10
    10, 5, 2             // no pair adding to 10
    10, 5, 2, 3          // no pair adding to 10
    10, 5, 2, 3, 7       // a pair adding to 10: 3 + 7, done
    
  • same issue here. I think the instruction is not clear enough. since we were asked to parse from left, then first pair should be [5,5] unless I misunderstand the instruction.

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

  • Loading more items...