Anonymous user
Talk:Two sum: Difference between revisions
→(from the task description) Given a sorted array of positive integers ...: added some comments.
(→(from the task description) Given a sorted array of positive integers ...: added some comments.) |
|||
Line 22:
-- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 01:17, 23 September 2017 (UTC)
:I updated the task. The assumption that the integers are positive (or non-negative) is absolutely not necessary. Also, that integers are "single" (unique?) does not guarantee a unique solution, so it's useless. For instance, look for the sum 9 in (1,2,7,8). And to see negative integers don't hurt, just add 1-min(a) to the array 'a', and add twice this number to the target. Actually, one could do the same with non-integers, but it would introduce unnecessary difficulties (floating-point is not exact, hence one can't rely on equality comparison). [[User:Eoraptor|Eoraptor]] ([[User talk:Eoraptor|talk]]) 15:15, 4 December 2017 (UTC)
:: You're preaching to the choir. However, my objection was that the ''given'' of non-negative integers as part of the specification, but zero was included in the case example, a confliction. Now that negative integers are allowed, some programming examples will need to be changed. Also, (for the 2<sup>nd</sup> REXX programming example), I've added a test case that included negative numbers as well as a duplicate number. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 23:01, 4 December 2017 (UTC)
:: Also, as for the use of non-integers, that isn't a problem for some languages, as not all floating point numbers are necessarily stored in binary, some programming languages can use ''decimal'' floating point. Other programming languages can also support scaled numbers, that is, '''2.3''' can be stored as an decimal integer, with the decimal point indicated to the appropriate location. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 23:01, 4 December 2017 (UTC)
|