-
-
Save gpaulu/4449746 to your computer and use it in GitHub Desktop.
Reddit Challenge 115 Description:
Let the term "sum-pair" be a pair of integers A and B such that the sum of A and B equals a given number C. As an example, let C be 10. Thus, the pairs (5, 5), (1, 9), (2, 8), etc. are all sum-pairs of 10.
Your goal is to write a program that, given an array through standard input (console), you echo out all sum…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sumPair options num :: [Int] -> Int -> [(Int,Int)] | |
sumPair options num = [(x,y) | x <- options, y <- options, x + y == num, x < y] ++ [(x,x) | x <- options, x*2 == num] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment