Talk:Two sum: Difference between revisions

From Rosetta Code
Content added Content deleted
m (typo)
m (no solution)
Line 10: Line 10:
== Some ambiguities ==
== Some ambiguities ==
What if there is more then one way to get the desired sum? Should it return '''all''' of the pairs or only '''a''' pair? Are we to assume the integers in the array are unique? --[[User:Thundergnat|Thundergnat]] ([[User talk:Thundergnat|talk]]) 22:21, 4 October 2016 (UTC)
What if there is more then one way to get the desired sum? Should it return '''all''' of the pairs or only '''a''' pair? Are we to assume the integers in the array are unique? --[[User:Thundergnat|Thundergnat]] ([[User talk:Thundergnat|talk]]) 22:21, 4 October 2016 (UTC)

What if there is no solution ?
E.g. when all numbers in the list are even,
and the desired sum is odd. -- [[User:Hajo|Hajo]] ([[User talk:Hajo|talk]]) 13:53, 5 October 2016 (UTC)

Revision as of 13:54, 5 October 2016

Eh? Are we quite sure this is stated correctly?

Because numbers[1] + numbers[3] = 2 + 19 = 21, return [0, 3]

Shoudn't that be return [1,3] ?

The above issue has been dealt with, though that does mean that the output from the original code example in C# is now wrong...

Some ambiguities

What if there is more then one way to get the desired sum? Should it return all of the pairs or only a pair? Are we to assume the integers in the array are unique? --Thundergnat (talk) 22:21, 4 October 2016 (UTC)

What if there is no solution ? E.g. when all numbers in the list are even, and the desired sum is odd. -- Hajo (talk) 13:53, 5 October 2016 (UTC)