Talk:Two sum: Difference between revisions
(→Some ambiguities: The proposed return type is not quite right yet) |
|||
Line 6: | Line 6: | ||
and the desired sum is odd. -- [[User:Hajo|Hajo]] ([[User talk:Hajo|talk]]) 13:53, 5 October 2016 (UTC) |
and the desired sum is odd. -- [[User:Hajo|Hajo]] ([[User talk:Hajo|talk]]) 13:53, 5 October 2016 (UTC) |
||
One way of putting it is that the proposed return type (list of integers '''[Int]''') is not quite right yet. The structure of the problem would be more clearly expressed by requiring the return of a list of lists of integers '''[[Int]]''' |
One way of putting it is that the proposed return type (list of integers '''[Int]''') is not quite right yet. The structure of the problem would be more clearly expressed by requiring the return of a list of lists of integers '''<pre>[[Int]]</pre>''' |
||
i.e. Returning an empty list where no solutions are found, and a list of more than one integer pair where multiple solutions are found. |
i.e. Returning an empty list where no solutions are found, and a list of more than one integer pair where multiple solutions are found. |
||
Revision as of 07:57, 17 October 2016
Some ambiguities (inappropriate return type)
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)
One way of putting it is that the proposed return type (list of integers [Int]) is not quite right yet. The structure of the problem would be more clearly expressed by requiring the return of a list of lists of integers
[[Int]]
i.e. Returning an empty list where no solutions are found, and a list of more than one integer pair where multiple solutions are found.
The English formulation of the task may also need a slight tweak – the phrase "If so, return indices of the two integers" skips a bit heavily over the thin ice – it seems to express an assumption than any solution would necessarily be unique. Hout (talk) 07:55, 17 October 2016 (UTC)