-- Problems/Problem023.hs
module Problems.Problem023 (p23) where

import Data.IntSet (toList, fromList)
import Helpers.Numbers

main = print p23

p23 :: Int
p23 = sum [1..20161] - (sum $ nub' $ abundantSums) where
    nub' = toList . fromList

abundantSums :: [Int]
abundantSums = [(x+y) | x <- ab, y <- ab, y >= x, (x+y) < 20162] where
    ab = abundants

abundants :: [Int]
abundants = filter (\x -> (sum $ divisors x) > x) [12..20149]
