The Task
This is my first challenge so apologies if it is very simple! In this challenge, your task is to write a program or function which takes in a list of integers and a desired sum and outputs a truthy or falsey value based on whether the list contains two numbers that can be summed together to achieve the desired sum.
Input
The input must be acquired in a standard way for your language. The list of integers can be any standard collection type for your language but cannot be a hashed set, sorted set, or any highly functional collection type. Don't assume the input is sorted, any valid integer type is acceptable.
The desired sum is also an integer and must be provided to your program as input.
Output
The output may be a function return, console log, writing to a file, etc... Any valid Truthy or Falsey value is acceptable.
Additional Rules
- The input list may or may not be sorted.
- Duplicate values may occur in the list
- The same item in the list may not be summed to itself to achieve the desired sum (Eg. [3,4,5] with desired sum 6 will expect False because 3 cannot be used twice)
- Standard loopholes are not allowed.
Test Cases
INPUT OUTPUT [3,4,5], 6 Falsey [1,2,3,4,5,6],11 Truthy [4,23,8174,42,-1],41 Truthy [1,1,1,1,1,3],3 Falsey [2,1,1,1,53,2],4 Truthy [2,2,2,2],4 Truthy [3],3 Falsey [],-43 Falsey This is code-golf, so the shortest code in bytes wins!
1for truthy? \$\endgroup\$