summaryrefslogtreecommitdiffstats
path: root/TestAufgabeFFP4.hs
diff options
context:
space:
mode:
Diffstat (limited to 'TestAufgabeFFP4.hs')
-rw-r--r--TestAufgabeFFP4.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/TestAufgabeFFP4.hs b/TestAufgabeFFP4.hs
index 55a257c..ff341e5 100644
--- a/TestAufgabeFFP4.hs
+++ b/TestAufgabeFFP4.hs
@@ -43,7 +43,28 @@ cases1 = TestLabel "knapsack" $ TestList [
43 (knapsack [(2,2), (3,3), (4,4), (5,5)] 5) 43 (knapsack [(2,2), (3,3), (4,4), (5,5)] 5)
44 ] 44 ]
45 45
46-- from Aufgabe3.hs
47binom :: (Integer, Integer) -> Integer
48binom (n, k)
49 | k == 0 || n == k = 1
50 | otherwise = binom (n-1, k-1) + binom (n-1, k)
51
46cases2 = TestLabel "binomDyn" $ TestList [ 52cases2 = TestLabel "binomDyn" $ TestList [
53 TestCase $ assertEqual "8 nCr [0..7]"
54 [ binom (8, i) | i <- [0..7] ]
55 [ binomDyn (8, i) | i <- [0..7] ],
56 TestCase $ assertEqual "1 nCr 1"
57 (binom (1, 1))
58 (binomDyn (1, 1)),
59 TestCase $ assertEqual "2 nCr 1"
60 (binom (2, 1))
61 (binomDyn (2, 1)),
62 TestCase $ assertEqual "18 nCr 12"
63 (binom (18, 12))
64 (binomDyn (18, 12)),
65 TestCase $ assertEqual "5 nCr 0"
66 (binom (5, 0))
67 (binomDyn (5, 0))
47 ] 68 ]
48 69
49tests :: [Test] 70tests :: [Test]