Skip to content

Instantly share code, notes, and snippets.

View gpaulu's full-sized avatar

Paul Unger gpaulu

  • Washington, D.C.
View GitHub Profile
@gpaulu
gpaulu / sumPair.hs
Last active September 24, 2021 13:46 — forked from anonymous/ sumPair.hs
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…
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]