1
0
Fork 0

Problem 60 alt attempt

This commit is contained in:
Jonathan Chan 2017-05-28 20:23:39 -07:00
parent 0b072a1efe
commit 768237c43e
4 changed files with 28 additions and 3 deletions

BIN
60_alt

Binary file not shown.

BIN
60_alt.hi

Binary file not shown.

View File

@ -1,11 +1,12 @@
{-# LANGUAGE BangPatterns #-}
import Data.List
upper = 10000
upper = 8000
isPrime :: Int -> Bool
isPrime x = null [k | k <- [2..x-1], k * k <= x, x `mod` k == 0]
primes = [x | x <- [2..upper], isPrime x]
!primes = [x | x <- [2..upper], isPrime x]
isPrimeNew :: Int -> Bool
isPrimeNew x
@ -17,4 +18,28 @@ isPrimePair a b = isPrime(read(show a ++ show b)) && isPrime(read(show b ++ show
primePairs = [(a, b) | a <- primes, b <- primes, a < b, isPrimePair a b]
main = print primePairs
primeSets = [(a, b, c, d, e) | a <- primes,
b <- primes,
a < b,
isPrimePair b a,
c <- primes,
b < c,
isPrimePair c a,
isPrimePair c b,
d <- primes,
c < d,
isPrimePair d a,
isPrimePair d b,
isPrimePair d c,
e <- primes,
d < e,
isPrimePair e a,
isPrimePair e b,
isPrimePair e c,
isPrimePair e d]
main = print $ head primeSets

BIN
60_alt.o

Binary file not shown.