diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-10-10 17:59:03 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-10-10 17:59:03 +0100 |
commit | b0d25291a32a0c2d085246d48639eb353ce9a206 (patch) | |
tree | 111911cd45ec62f77855fe3b4ed87e536d529075 /testsuite/tests/dph | |
parent | cecf7b547dceb15478d0bbb707fc6e60612050fc (diff) | |
download | haskell-b0d25291a32a0c2d085246d48639eb353ce9a206.tar.gz |
Whitespace only in dph/diophantine
Diffstat (limited to 'testsuite/tests/dph')
-rw-r--r-- | testsuite/tests/dph/diophantine/DiophantineVect.hs | 16 | ||||
-rw-r--r-- | testsuite/tests/dph/diophantine/Main.hs | 55 |
2 files changed, 35 insertions, 36 deletions
diff --git a/testsuite/tests/dph/diophantine/DiophantineVect.hs b/testsuite/tests/dph/diophantine/DiophantineVect.hs index 5851eb5e39..981b9ad62d 100644 --- a/testsuite/tests/dph/diophantine/DiophantineVect.hs +++ b/testsuite/tests/dph/diophantine/DiophantineVect.hs @@ -14,20 +14,20 @@ solution3' a `cutTo` b = sliceP 0 (lengthP b) a sumpri xx = productP [: pow p x | p <- primes `cutTo` xx | x <- xx :] distinct xx = productP [: x I.+ 1 | x <- xx :] - + series :: [:Int:] -> Int -> [:[:Int:]:] - series xs n + series xs n | n == 1 = [: [: 0 :] :] - | otherwise = [: [: x :] +:+ ps + | otherwise = [: [: x :] +:+ ps | x <- xs , ps <- series (I.enumFromToP 0 x) (n I.- 1) :] - - prob x y - = let xx = [: (sumpri m ,m) + + prob x y + = let xx = [: (sumpri m ,m) | m <- series (I.enumFromToP 1 3) x - , distinct [: x I.* 2 | x <- m :] > y :] + , distinct [: x I.* 2 | x <- m :] > y :] i = minIndexP [: a | (a, b) <- xx :] - in xx !: i + in xx !: i in prob 5 200 diff --git a/testsuite/tests/dph/diophantine/Main.hs b/testsuite/tests/dph/diophantine/Main.hs index e3130f03a8..571566ebcb 100644 --- a/testsuite/tests/dph/diophantine/Main.hs +++ b/testsuite/tests/dph/diophantine/Main.hs @@ -10,34 +10,33 @@ import Data.Array.Parallel.Prelude -- Solution for the 108th Euler problem. -- From the Haskell Wiki solution1 - = let primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73] - series _ 1 = [[0]] - series xs n = [x:ps | x <- xs, ps <- series [0..x] (n-1) ] - distinct = product . map (+1) - sumpri x = product $ zipWith (^) primes x + = let primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73] + series _ 1 = [[0]] + series xs n = [x:ps | x <- xs, ps <- series [0..x] (n-1) ] + distinct = product . map (+1) + sumpri x = product $ zipWith (^) primes x - prob x y = minimum [ (sumpri m ,m) - | m <- series [1..3] x - , (>y) $ distinct $ map (*2) m] - in prob 5 200 + prob x y = minimum [ (sumpri m ,m) + | m <- series [1..3] x + , (>y) $ distinct $ map (*2) m] + in prob 5 200 solution2 - = let primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73] - series _ 1 = [[0]] - series xs n = [x:ps | x <- xs, ps <- series [0..x] (n-1) ] - distinct xx = product [ x + 1 | x <- xx ] - sumpri xx = product $ zipWith (^) primes xx - - prob x y = minimum [ (sumpri m ,m) - | m <- series [1..3] x - , (distinct $ map (*2) m) > y ] - in prob 5 200 - - -main - = do print solution1 - print solution2 - print solution3 - - -
\ No newline at end of file + = let primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73] + series _ 1 = [[0]] + series xs n = [x:ps | x <- xs, ps <- series [0..x] (n-1) ] + distinct xx = product [ x + 1 | x <- xx ] + sumpri xx = product $ zipWith (^) primes xx + + prob x y = minimum [ (sumpri m ,m) + | m <- series [1..3] x + , (distinct $ map (*2) m) > y ] + in prob 5 200 + + +main + = do print solution1 + print solution2 + print solution3 + + |