{-# LANGUAGE NoImplicitPrelude #-} module Phladiprelio.Tests where import GHC.Base import GHC.Int (Int8) import GHC.Enum (toEnum) import GHC.Real (quot,rem) import GHC.Num ((+),(-),(*)) import GHC.List (elem) sel :: Int -> [[Int8]] sel x | x == 1 || x < 0 || x > 179 = [] | x == 0 || x == 4 = [[1],[2,1],[3,2],[4,3,2],[5,4,3],[6,5,4,3,2]] -- all cases are present: 2, 3, 4, 5, 6, 7. Therefore, the slowest ones. | x == 2 || x == 5 = [[1],[2],[3],[4,3],[5,4],[6,5,4]] | x == 7 = [[0],[1,0],[1,0],[1,0],[1,0],[1,0]] | x == 8 = [[0],[1,0],[1,0],[2,1,0],[2,1,0],[2,1,0]] | x == 9 = [[0],[1,0],[1,0],[2,1,0],[3,2,1,0],[3,2,1,0]] ------------------------------------------------------------------ | x >= 20 && x <= 26 && x /= 21 = [[1]] -- at least 7 is omitted, but probably 6, or even 5, or even 4, or even 3. 2 is however present. | x >= 27 && x <= 29 = [[0]] | x == 30 || x == 34 = [[1],[2,1]] | x == 32 || x == 35 = [[1],[2]] | x >= 37 && x <= 39 = [[0],[1,0]] | x == 40 || x == 44 = [[1],[2,1],[3,2]] | x == 42 || x == 45 = [[1],[2],[3]] | x >= 47 && x <= 49 = [[0],[1,0],[1,0]] | x == 50 || x == 54 = [[1],[2,1],[3,2],[4,3,2]] | x == 52 || x == 55 = [[1],[2],[3],[4,3]] | x == 57 = [[0],[1,0],[1,0],[1,0]] | x == 58 || x == 59 = [[0],[1,0],[1,0],[2,1,0]] | x == 60 || x == 64 = [[1],[2,1],[3,2],[4,3,2],[5,4,3]] | x == 62 || x == 65 = [[1],[2],[3],[4,3],[5,4]] | x == 67 = [[0],[1,0],[1,0],[1,0],[1,0]] | x == 68 = [[0],[1,0],[1,0],[2,1,0],[2,1,0]] | x == 69 = [[0],[1,0],[1,0],[2,1,0],[3,2,1,0]] ------------------------------------------------------ | x == 70 || x == 74 = [[2,1],[3,2],[4,3,2],[5,4,3],[6,5,4,3,2]] -- at least 2 is omitted, but probably 3 and even 4. 5, 6 and 7 are present. | x == 72 || x == 75 = [[2],[3],[4,3],[5,4],[6,5,4]] | x == 77 = [[1,0],[1,0],[1,0],[1,0],[1,0]] | x == 78 = [[1,0],[1,0],[2,1,0],[2,1,0],[2,1,0]] | x == 79 = [[1,0],[1,0],[2,1,0],[3,2,1,0],[3,2,1,0]] | x == 80 || x == 84 = [[3,2],[4,3,2],[5,4,3],[6,5,4,3,2]] | x == 82 || x == 85 = [[3],[4,3],[5,4],[6,5,4]] | x == 87 = [[1,0],[1,0],[1,0],[1,0]] | x == 88 = [[1,0],[2,1,0],[2,1,0],[2,1,0]] | x == 89 = [[1,0],[2,1,0],[3,2,1,0],[3,2,1,0]] | x == 90 || x == 94 = [[4,3,2],[5,4,3],[6,5,4,3,2]] | x == 92 || x == 95 = [[4,3],[5,4],[6,5,4]] | x == 97 = [[1,0],[1,0],[1,0]] | x == 98 = [[2,1,0],[2,1,0],[2,1,0]] | x == 99 = [[2,1,0],[3,2,1,0],[3,2,1,0]] ------------------------------------------------------------------------ | x == 100 || x == 104 = [[1],[2,1],[4,3,2],[6,5,4,3,2]] -- 4 and 6 are omitted, just present the ones from: 2, 3, 5, 7. | x == 102 || x == 105 = [[1],[2],[4,3],[6,5,4]] | x == 107 = [[0],[1,0],[1,0],[1,0]] | x == 108 = [[0],[1,0],[2,1,0],[2,1,0]] | x == 109 = [[0],[1,0],[2,1,0],[3,2,1,0]] ------------------------------------------------------------------ | x == 150 || x == 154 = [[1],[2,1],[4,3,2]] -- 4, 6, 7 are omitted but 2, 3, 5 are present. | x == 152 || x == 155 = [[1],[2],[4,3]] | x == 157 = [[0],[1,0],[1,0]] | x == 158 || x == 159 = [[0],[1,0],[2,1,0]] ------------------------------------------------------ | x == 170 || x == 174 = [[2,1],[4,3,2],[6,5,4,3,2]] -- just 3, 5 and 7 are present | x == 172 || x == 175 = [[2],[4,3],[6,5,4]] | x == 177 = [[1,0],[1,0],[1,0]] | x == 178 = [[1,0],[2,1,0],[2,1,0]] | x == 179 = [[1,0],[2,1,0],[3,2,1,0]] ----------------------------------------------------------------------- | otherwise = [[1],[1],[2,1],[3,2,1],[3,2],[4,3,2]] -------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------- sel2 :: Int -> [Int8] sel2 y | y == 1 || y < 0 || y > 179 = [] | (rem y 10 `elem` [1,3,6]) || y >= 0 && y <= 9 = [2..7] | y >= 20 && y <= 69 = [2..toEnum (y `quot` 10)] | y >= 70 && y <= 99 = [toEnum (y `quot` 10) - 4..7] | y >= 100 && y <= 109 = [2,3,5,7] | y >= 150 && y <= 159 = [2,3,5] | y >= 170 && y <= 179 = [3,5,7] | otherwise = [2..7] minMax11ByCList :: Ord a => (a -> a -> Ordering) -> [a] -> (a, a) -- Is rewritten from the 'Data.MinMax.Preconditions.minMax11ByC' from @subG@ package. minMax11ByCList g xs@(x:y:ys) = foldr f (if x > y then (y, x) else (x, y)) ys where f z (x,y) | g z x == LT = (z,y) | g z y == GT = (x,z) | otherwise = (x,y) minMax11ByCList _ _ = undefined -- Is not intended to be used for lists with less than two elements.