From 0904db6a9f2c76ae58fe6ed6e8d813fe0f45c27b Mon Sep 17 00:00:00 2001 From: FP10 Uebungsteilnehmer 0726236 Date: Tue, 16 Nov 2010 00:14:41 +0100 Subject: [PATCH] aufg4 part2 --- Aufgabe4.hs | 9 +++-- Aufgabe4.hs_1.out | 84 +++++++++++++++++++++++++++++++++++++++++++++++ Aufgabe5.hs | 1 + 3 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 Aufgabe4.hs_1.out create mode 100644 Aufgabe5.hs diff --git a/Aufgabe4.hs b/Aufgabe4.hs index 2a13657..646739c 100755 --- a/Aufgabe4.hs +++ b/Aufgabe4.hs @@ -30,16 +30,15 @@ mmerge x y = [x!!index ++ y!!index | index <- [0..(min (length x) (length y))-1] data STree = Nil | SNode Integer STree STree deriving Show transform :: Tree -> STree ---transform :: Tree -> [Integer] transform t = toStree (sort (undup (concat (writeLayer t BottomUp)))) undup :: [Integer] -> [Integer] -undup [] = [] +undup [] = [] undup (x:xs) = x : undup (filter (\y -> not (x == y)) xs) toStree :: [Integer] -> STree toStree [] = Nil -toStree (x:xs) = SNode x Nil (toStree xs) +toStree (x:xs) = (SNode x Nil (toStree xs)) @@ -62,8 +61,8 @@ instance Main.Eq Result where a == b = show a == show b ---path :: Graph -> Vertex -> Vertex -> Cost -> Result ---path _ _ _ _ = Invalid +path :: Graph -> Vertex -> Vertex -> Cost -> Result +path _ _ _ _ = Invalid diff --git a/Aufgabe4.hs_1.out b/Aufgabe4.hs_1.out new file mode 100644 index 0000000..1d8dabb --- /dev/null +++ b/Aufgabe4.hs_1.out @@ -0,0 +1,84 @@ +Punkte pro Testfall: 5; Abzug pro fehlerhaften Testfall: 0; Maximum: 25 + +Testfall: {-1,1-}writeLayer (Leaf 21) BottomUp == [[21]]; Testfall OK +Testfall: {-1,2-}writeLayer (Node 11 (Leaf 21) (Leaf 22)) BottomUp == [[21,22],[11]]; Testfall OK +Testfall: {-1,3-}writeLayer (Node 11(Leaf 21)(Node 22 (Leaf 31)(Leaf 32))) BottomUp ; Testfall FALSCH +Erwartet: {-1,3-}writeLayer (Node 11(Leaf 21)(Node 22 (Leaf 31)(Leaf 32))) BottomUp == [[31,32],[21,22],[11]] +Ausgabe: {-1,3-}writeLayer (Node 11(Leaf 21)(Node 22 (Leaf 31)(Leaf 32))) BottomUp ==[[21,31,32],[11]] +Testfall: {-1,4-}writeLayer (Node 11(Leaf 21)(Node 22 (Leaf 31)(Leaf 32))) TopDown ; Testfall FALSCH +Erwartet: {-1,4-}writeLayer (Node 11(Leaf 21)(Node 22 (Leaf 31)(Leaf 32))) TopDown == [[11],[21,22],[31,32]] +Ausgabe: {-1,4-}writeLayer (Node 11(Leaf 21)(Node 22 (Leaf 31)(Leaf 32))) TopDown ==[[11],[21,22]] +Testfall: {-1,5-}take 5 [(n::Integer,r,c)|n<-[1..6],c<-[[1..(2^(n+1)-1)]],r<-[let t 0 i=(Leaf i);t(m+1)i=Node i(t m(2*i))(t m(2*i+1));in concat(writeLayer(t n 1)TopDown)],r/=c]== []; Testfall OK + +Testfaelle OK: 3; Testfaelle FALSCH: 2 +Punkte : 15 + +Punkte pro Testfall: 5; Abzug pro fehlerhaften Testfall: 0; Maximum: 25 + +Testfall: {-2,1-}transform (Leaf 27) ; Testfall FALSCH +Erwartet: {-2,1-}transform (Leaf 27) == (SNode 27 Nil Nil) +Ausgabe: {-2,1-}transform (Leaf 27) ==SNode 27 Nil Nil +Testfall: {-2,1-}[1|(SNode 27 Nil Nil)<-[transform (Leaf 27)]] == [1]; Testfall OK +Testfall: {-2,1'-}Nil ; Testfall FALSCH +Erwartet: {-2,1'-}Nil == Nil +Ausgabe: {-2,1'-}Nil ==Nil +Testfall: {-2,2-}show (transform (Leaf 27)) == show (SNode 27 Nil Nil); Testfall OK +Testfall: {-2,3-}let r=[0..1];f p=[Leaf i|i<-r]++[(Node i l r)|i<-r,l<-p,r<-p];g Nil=[];g(SNode i l r)=g(l)++[i]++g(r)in take 5[u|t<-(f.f.f)[],u<-[(g.transform)t],u/=[0],u/=[1],u/=[0,1]] == []; Testfall OK +Testfall: {-2,4-}take 5[(n::Integer,r,c)|n<-[1..9],r<-[let t 0=(Leaf 0);t(m+1)=Node m(t m)(t m);fl(Nil)=[];fl(SNode x l r)=fl(l)++[x]++fl(r)in (fl.transform)((t n))],c<-[[0..(n-1)]],c/=r] == []; Testfall OK +Testfall: {-2,5-}take 5[(n::Integer,r,c)|n<-[1..7],r<-[let t 0 i=(Leaf i);t(m+1)i=Node i(t m(2*i))(t m(2*i+1));fl(Nil)=[];fl(SNode x l r)=fl(l)++[x]++fl(r)in (fl.transform)((t n 1))],c<-[[1..(2^(n+1))-1]],c/=r] == []; Testfall OK + +Testfaelle OK: 5; Testfaelle FALSCH: 2 +Punkte : 25 + +Punkte pro Testfall: 5; Abzug pro fehlerhaften Testfall: 0; Maximum: 25 + +Testfall: {-3,1-}(path(Graph[(1,[(2,1)])])9 2 1) == Invalid; Testfall OK +Testfall: {-3,1'-}[1|Invalid<-[path(Graph[(1,[(2,1)])])9 2 1]] == [1]; Testfall OK +Testfall: {-3,2-}[k|k<-[1..9],path(Graph[(1,[(2,1)])])1 2 k/=Yes] ; Testfall FALSCH +Erwartet: {-3,2-}[k|k<-[1..9],path(Graph[(1,[(2,1)])])1 2 k/=Yes] == [] +Ausgabe: {-3,2-}[k|k<-[1..9],path(Graph[(1,[(2,1)])])1 2 k/=Yes] ==[1,2,3,4,5,6,7,8,9] +Testfall: {-3,2'-}let ny Yes=False;ny _=True in[k|k<-[1..9],ny(path(Graph[(1,[(2,1)])])1 2 k)] ; Testfall FALSCH +Erwartet: {-3,2'-}let ny Yes=False;ny _=True in[k|k<-[1..9],ny(path(Graph[(1,[(2,1)])])1 2 k)] == [] +Ausgabe: {-3,2'-}let ny Yes=False;ny _=True in[k|k<-[1..9],ny(path(Graph[(1,[(2,1)])])1 2 k)] ==[1,2,3,4,5,6,7,8,9] +Testfall: {-3,3-}let nn No=False;nn _ =True;m=10;r=[1..m];g=Graph[(i,[(j,1)|j<-r,(j`mod`3)>(i`mod`3)])|i<-r]in[i|i<-r,nn(path g 1 i m)] ; Testfall FALSCH +Erwartet: {-3,3-}let nn No=False;nn _ =True;m=10;r=[1..m];g=Graph[(i,[(j,1)|j<-r,(j`mod`3)>(i`mod`3)])|i<-r]in[i|i<-r,nn(path g 1 i m)] == [2,5,8] +Ausgabe: {-3,3-}let nn No=False;nn _ =True;m=10;r=[1..m];g=Graph[(i,[(j,1)|j<-r,(j`mod`3)>(i`mod`3)])|i<-r]in[i|i<-r,nn(path g 1 i m)] ==[1,2,3,4,5,6,7,8,9,10] +Testfall: {-3,3'-}let nn No=False;nn _ =True;m=10;r=[1..m];g=Graph[(i,[(j,1)|j<-r,(j`mod`3)>(i`mod`3)])|i<-r]in[i|i<-r,nn(path g 1 i m)] ; Testfall FALSCH +Erwartet: {-3,3'-}let nn No=False;nn _ =True;m=10;r=[1..m];g=Graph[(i,[(j,1)|j<-r,(j`mod`3)>(i`mod`3)])|i<-r]in[i|i<-r,nn(path g 1 i m)] == [1,2,5,8] +Ausgabe: {-3,3'-}let nn No=False;nn _ =True;m=10;r=[1..m];g=Graph[(i,[(j,1)|j<-r,(j`mod`3)>(i`mod`3)])|i<-r]in[i|i<-r,nn(path g 1 i m)] ==[1,2,3,4,5,6,7,8,9,10] +Testfall: {-3,4-}let ny Yes=False;ny _=True in[n|n<-[1..15],ny(path(Graph[(i,[(i+1,1)])|i<-[1..n]])1 n(n-1))] ; Testfall FALSCH +Erwartet: {-3,4-}let ny Yes=False;ny _=True in[n|n<-[1..15],ny(path(Graph[(i,[(i+1,1)])|i<-[1..n]])1 n(n-1))] == [] +Ausgabe: {-3,4-}let ny Yes=False;ny _=True in[n|n<-[1..15],ny(path(Graph[(i,[(i+1,1)])|i<-[1..n]])1 n(n-1))] ==[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] +Testfall: {-3,5-}let ny Yes=False;ny _=True in[n|n<-[1..15],ny(path(Graph[(i,[(j,j-i)|j<-[i+1..n]])|i<-[1..n]])1 n (n-1))] ; Testfall FALSCH +Erwartet: {-3,5-}let ny Yes=False;ny _=True in[n|n<-[1..15],ny(path(Graph[(i,[(j,j-i)|j<-[i+1..n]])|i<-[1..n]])1 n (n-1))] == [] +Ausgabe: {-3,5-}let ny Yes=False;ny _=True in[n|n<-[1..15],ny(path(Graph[(i,[(j,j-i)|j<-[i+1..n]])|i<-[1..n]])1 n (n-1))] ==[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] +Testfall: {-3,5'-}let nn No=False;nn _ =True in[n|n<-[15],nn(path(Graph[(i,[(i+1,1)])|i<-[1..n]])1 n(n-2))] ; Testfall FALSCH +Erwartet: {-3,5'-}let nn No=False;nn _ =True in[n|n<-[15],nn(path(Graph[(i,[(i+1,1)])|i<-[1..n]])1 n(n-2))] == [] +Ausgabe: {-3,5'-}let nn No=False;nn _ =True in[n|n<-[15],nn(path(Graph[(i,[(i+1,1)])|i<-[1..n]])1 n(n-2))] ==[15] + +Testfaelle OK: 2; Testfaelle FALSCH: 7 +Punkte : 10 + +Punkte pro Testfall: 5; Abzug pro fehlerhaften Testfall: 0; Maximum: 25 + +Testfall: {-4,1-}minpath (Graph[(1,[(2,1)])])1 2 ; Testfall FALSCH +Erwartet: {-4,1-}minpath (Graph[(1,[(2,1)])])1 2 == ([1,2],1) +Ausgabe: {-4,1-}minpath (Graph[(1,[(2,1)])])1 2 ==ERROR - Undefined variable "minpath" +Testfall: {-4,2-}let m=5;r=[1..m];g=Graph[(i,[(j,1)|j<-r,i/=j,(j`mod`3)>=(i`mod`3)])|i<-r]in take 11[c|i<-r,j<-r,i/=j,(_,c)<-[minpath g i j]] ; Testfall FALSCH +Erwartet: {-4,2-}let m=5;r=[1..m];g=Graph[(i,[(j,1)|j<-r,i/=j,(j`mod`3)>=(i`mod`3)])|i<-r]in take 11[c|i<-r,j<-r,i/=j,(_,c)<-[minpath g i j]] == [1,0,1,1,0,0,0,1,1,1,1] +Ausgabe: {-4,2-}let m=5;r=[1..m];g=Graph[(i,[(j,1)|j<-r,i/=j,(j`mod`3)>=(i`mod`3)])|i<-r]in take 11[c|i<-r,j<-r,i/=j,(_,c)<-[minpath g i j]] ==ERROR - Undefined variable "minpath" +Testfall: {-4,3-}let m=4;r=[1..m];g=Graph[(i,[(j,1)|j<-r,i/=j,(j`mod`3)/=(i`mod`3)])|i<-r]in take 9 ([c|i<-r,j<-r,i/=j,(_,c)<-[minpath g i j]]) ; Testfall FALSCH +Erwartet: {-4,3-}let m=4;r=[1..m];g=Graph[(i,[(j,1)|j<-r,i/=j,(j`mod`3)/=(i`mod`3)])|i<-r]in take 9 ([c|i<-r,j<-r,i/=j,(_,c)<-[minpath g i j]]) == [1,1,2,1,1,1,1,1,1] +Ausgabe: {-4,3-}let m=4;r=[1..m];g=Graph[(i,[(j,1)|j<-r,i/=j,(j`mod`3)/=(i`mod`3)])|i<-r]in take 9 ([c|i<-r,j<-r,i/=j,(_,c)<-[minpath g i j]]) ==ERROR - Undefined variable "minpath" +Testfall: {-4,4-}let m=5;r=[1..m];g=Graph[(i,[(j,1)|j<-r,i/=j,(j`mod`3)/=(i`mod`3)])|i<-r]in take 11([c|i<-r,j<-r,i/=j,(_,c)<-[minpath g i j]]) ; Testfall FALSCH +Erwartet: {-4,4-}let m=5;r=[1..m];g=Graph[(i,[(j,1)|j<-r,i/=j,(j`mod`3)/=(i`mod`3)])|i<-r]in take 11([c|i<-r,j<-r,i/=j,(_,c)<-[minpath g i j]]) == [1,1,2,1,1,1,1,2,1,1,1] +Ausgabe: {-4,4-}let m=5;r=[1..m];g=Graph[(i,[(j,1)|j<-r,i/=j,(j`mod`3)/=(i`mod`3)])|i<-r]in take 11([c|i<-r,j<-r,i/=j,(_,c)<-[minpath g i j]]) ==ERROR - Undefined variable "minpath" +Testfall: {-4,5'-}let m=6;r=[1..m];g=Graph[(i,[(j,1)|j<-r,i/=j,(j`mod`3)/=(i`mod`3)])|i<-r]in take 11([c|i<-r,j<-r,i/=j,(_,c)<-[minpath g i j]]) ; Testfall FALSCH +Erwartet: {-4,5'-}let m=6;r=[1..m];g=Graph[(i,[(j,1)|j<-r,i/=j,(j`mod`3)/=(i`mod`3)])|i<-r]in take 11([c|i<-r,j<-r,i/=j,(_,c)<-[minpath g i j]]) == [1,1,2,1,1,1,1,1,2,1,1] +Ausgabe: {-4,5'-}let m=6;r=[1..m];g=Graph[(i,[(j,1)|j<-r,i/=j,(j`mod`3)/=(i`mod`3)])|i<-r]in take 11([c|i<-r,j<-r,i/=j,(_,c)<-[minpath g i j]]) ==ERROR - Undefined variable "minpath" + +Testfaelle OK: 0; Testfaelle FALSCH: 5 +Punkte : 0 + +Punkte gesamt: 50 + diff --git a/Aufgabe5.hs b/Aufgabe5.hs new file mode 100644 index 0000000..4ba2805 --- /dev/null +++ b/Aufgabe5.hs @@ -0,0 +1 @@ +-- -- 2.43.0