summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AufgabeFFP8.hs34
1 files changed, 31 insertions, 3 deletions
diff --git a/AufgabeFFP8.hs b/AufgabeFFP8.hs
index 298898b..e667654 100644
--- a/AufgabeFFP8.hs
+++ b/AufgabeFFP8.hs
@@ -47,13 +47,41 @@ search_countlist = length . takeWhile (/= 0) . elems
47 47
48-- basic divide-and-conquer 48-- basic divide-and-conquer
49minfree_b :: [Int] -> Int 49minfree_b :: [Int] -> Int
50minfree_b xs = if (null ([0..b-1] \\ us))
51 then (head ([b..] \\ vs))
52 else (head ([0..] \\ us))
53 where
54 (us, vs) = partition (<b) xs
55 b = 1 + (length xs) `div` 2
50 56
51-- refined divide-and-conquer 57-- refined divide-and-conquer
52--minfree_r :: [Int] -> Int 58minfree_r :: [Int] -> Int
59minfree_r xs = minfrom 0 xs
60
61minfrom :: Int -> [Int] -> Int
62minfrom a xs
63 | null xs = a
64 | length us == b-a = minfrom b vs
65 | otherwise = minfrom a us
66 where
67 (us, vs) = partition (<b) xs
68 b = a + 1 + (length xs) `div` 2
53 69
54-- optimised divide-and-conquer 70-- optimised divide-and-conquer
55--minfree_o :: [Int] -> Int 71minfree_o :: [Int] -> Int
56-- 72minfree_o xs = minfrom_o 0 (length xs, xs)
73
74minfrom_o :: Int -> (Int, [Int]) -> Int
75minfrom_o a (n, xs)
76 | n == 0 = a
77 | m == b-a = minfrom_o b (n-m, vs)
78 | otherwise = minfrom_o a (m, us)
79 where
80 (us, vs) = partition (<b) xs
81 b = a + 1 + n `div` 2
82 m = length us
83
84
57-- basic divide-and-conquer mittels higher order function 85-- basic divide-and-conquer mittels higher order function
58--minfree_bhof :: [Int] -> Int 86--minfree_bhof :: [Int] -> Int
59 87