Two sum: Difference between revisions

(Added solution for Action!)
Line 1,441:
<pre>
[2,5]
</pre>
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<lang Mathematica>ttwoSum[data_List, sum_] :=
Block[{indices = Subsets[Range@Length@data, {2}]},
Cases[indices, _?(Total@data[[#]] == sum &)]]
 
twoSum[{0, 2, 11, 19, 90}, 21] // TableForm</lang>
 
{{out}}<pre>
2 4
</pre>
 
Anonymous user