| 123456789101112131415161718192021222324252627282930 |
- import Utils
- import Data.List
- import Data.Maybe
- --import Debug.Trace
- --import Text.Printf
- numOfPrimes :: Int -> Int -> Int
- numOfPrimes a b = go' 0
- where
- go' :: Int -> Int
- go' n
- -- | trace (printf "go' n=%-5d r=%-5d" n r) False = undefined
- | otherwise = if (isPrime r) then go' (n+1) else n
- where r = (n*n) + (a*n) + b
- solution :: Int
- solution = combinations2 [aDLimit..aULimit] [bDLimit..bULimit]
- |> mapFindMaxInitial (uncurry numOfPrimes)
- |> (uncurry (*))
- where
- aULimit = 999
- bULimit = 1000
- aDLimit = -999
- bDLimit = -1000
- main :: IO ()
- main = putStrLn ("Solution: " ++ show solution)
|