diff options
Diffstat (limited to 'AufgabeFFP8.hs')
| -rw-r--r-- | AufgabeFFP8.hs | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/AufgabeFFP8.hs b/AufgabeFFP8.hs index d328ae8..fe9c894 100644 --- a/AufgabeFFP8.hs +++ b/AufgabeFFP8.hs | |||
| @@ -96,26 +96,27 @@ divideAndConquer indiv solve divide combine initPb = dAC initPb | |||
| 96 | 96 | ||
| 97 | -- minfree basic daq higher order | 97 | -- minfree basic daq higher order |
| 98 | 98 | ||
| 99 | b_indiv :: Int -> [Int] -> Bool | 99 | minfree_bhof :: [Int] -> Int |
| 100 | b_indiv l xs = length xs < l | 100 | minfree_bhof xs = divideAndConquer b_indiv b_solve b_divide b_combine (False, xs) |
| 101 | 101 | ||
| 102 | b_solve :: [Int] -> [Int] | 102 | b_indiv :: (Bool, [Int]) -> Bool |
| 103 | b_solve = id | 103 | b_indiv (b, _) = b |
| 104 | 104 | ||
| 105 | b_divide :: Int -> [Int] -> [[Int]] | 105 | b_solve :: (Bool, [Int]) -> Int |
| 106 | b_divide b xs = [us, vs] | 106 | b_solve (_, xs) = head xs |
| 107 | where (us,vs) = partition (<b) xs | 107 | |
| 108 | 108 | ||
| 109 | b_combine :: Int -> [Int] -> [[Int]] -> [Int] | 109 | |
| 110 | b_combine b _ (us:vs:[]) = if (null ([0..b-1] \\ us)) | 110 | b_divide :: (Bool, [Int]) -> [(Bool, [Int])] |
| 111 | then ([b..] \\ vs) | 111 | b_divide (n, xs) = if (null ([0..b-1] \\ us)) |
| 112 | else ([0..] \\ us) | 112 | then [(True, [b..] \\ vs)] |
| 113 | 113 | else [(True, [0..] \\ us)] | |
| 114 | minfree_bhof :: [Int] -> Int | 114 | where |
| 115 | minfree_bhof [] = 0 | 115 | (us, vs) = partition (<b) xs |
| 116 | minfree_bhof xs = head $ divideAndConquer (b_indiv (length xs)) b_solve (b_divide b) (b_combine b) xs | 116 | b = 1 + (length xs) `div` 2 |
| 117 | where b = 1+(length xs) `div` 2 | ||
| 118 | 117 | ||
| 118 | b_combine :: (Bool, [Int]) -> [Int] -> Int | ||
| 119 | b_combine xs sols = head sols | ||
| 119 | 120 | ||
| 120 | -- minfree refined daq higher order | 121 | -- minfree refined daq higher order |
| 121 | 122 | ||
