It’s just a general question: shouldn’t the return of `pairwise([0, 0, 0, 0, 1, 1], 1)`

be `9`

since the indices of 1 are 4 and 5 so the smallest sum is 9!?

The instructions state:

```
If multiple pairs are possible that have the same numeric elements but different indices,
return the smallest sum of indices. Once an element has been used, it cannot be
reused to pair with another.
```

So in the case of:

```
pairwise([0, 0, 0, 0, 1, 1], 1)
```

Indices 0 and 4 sum to 1

and

Indices 1 and 5 sum to 1

So we have to sum all of these indices, which would be (0 + 4 + 1 + 5) to give us 10.

Thanks, @rmdawson71 for clarification. Very helpful!

I don’t really follow your explanation. In the example you gave, you have two sums of indices that use the same numeric elements:

0 + 4 = 4.

1 + 5 = 6.

The instructions state “return the smallest sum of indices.” The smallest sum of indices is 4, so the answer to that example should be 4, not 10.

That is correct. It does not say return the smallest sum of a pair of indices (like 0+4 or 1+5). It is sum of indices for the multiple pairs (all four indices).

But it doesn’t seem to apply to the pairwise([1, 1, 1], 2) output.

arr[0] + arr[1] = 2

arr[1] + arr[2] = 2

0 + 1 = 1

1 + 2 = 3

3 + 1 = 4

For **pairwise([1, 1, 1], 2),** you use arr[0] + arr[1] = 2. So the sum of the indices would be 1 because 0 + 1 = 1

You can not use the same element to pair with another element once it has been used.

I think I get it now. It’s not the element’s value that cannot be repeated, but the element itself.

Thanks

Thank you, was wondering the same thing, thanks for explanation.