module Exercise_1_Sol where import Test.QuickCheck {-G1.1-} threeAscending :: Integer -> Integer -> Integer -> Bool threeAscending x y z = x < y && y < z fourEqual :: Integer -> Integer -> Integer -> Integer -> Bool fourEqual w x y z = w == x && x == y && y == z {- - threeAscending (2+3) 5 (11 `div` 2) - = (2+3) < 5 && 5 < (11 `div` 2) - = 5 < 5 && 5 < (11 `div` 2) - = False && 5 < (11 `div` 2) - = False - - fourEqual (2 + 3) 5 (11 `div` 2) (21 `mod` 11) - = (2 + 3) == 5 && 5 == (11 `div` 2) && (11 `div 2) == (21 `mod` 11) - = 5 == 5 && 5 == (11 `div` 2) && (11 `div 2) == (21 `mod` 11) - = True && 5 == (11 `div` 2) && (11 `div 2) == (21 `mod` 11) - = 5 == (11 `div` 2) && (11 `div 2) == (21 `mod` 11) - = 5 == 5 && 5 == (21 `mod` 11) - = True && 5 == (21 `mod` 11) - = 5 == (21 `mod` 11) - = 5 == 10 - = False -} {- G1.2 -} fac :: Integer -> Integer fac n | n > 0 = n * fac (n - 1) | otherwise = 1 sum_eleven :: Integer -> Integer sum_eleven n = sum_eleven' n 10 sum_eleven' :: Integer -> Integer -> Integer sum_eleven' n 0 = n sum_eleven' n m = n + m + sum_eleven' n (m - 1) {- G1.3 -} g :: Integer -> Integer g n = if n < 10 then n*n else n max_g :: Integer -> Integer max_g 0 = 0 max_g n | n > 0 = if (g mg > g n) then mg else n | otherwise = 0 where mg = max_g (n - 1) max_g' :: Integer -> Integer max_g' n | n < 0 = 0 | n >= 10 && n < 81 = 9 | otherwise = n prop_max_g n = max_g n == max_g' n {-H1.1-} {-WETT-} allDistinct :: Integer -> Integer -> Integer -> Integer -> Integer -> Bool allDistinct a b c d e = a /= b && a /= c && a /= d && a /= e && b /= c && b /= d && b /= e && c /= d && c /= e && d /= e {-TTEW-} {-H1.2-} f :: Integer -> Integer -> Integer f 0 _ = 0 f _ 0 = 0 f m n = 1 + f (f (n - 1) m) (f (m - 1) n) prop_f m n = m >= 0 ==> n >= 0 ==> f m n == min m n {-H1.3-} isPower' :: Integer -> Integer -> Integer -> Bool isPower' x a b | b > x = False | otherwise = x == a ^ b || isPower' x a (b+1) isPower :: Integer -> Integer -> Bool isPower x a = isPower' x a 0