-- Testfaelle fuer Aufgabenblatt 10 -- Testfaelle fuer Aufgabe 1 testQ1 = (reverse [1..9]) testQ1S = [1..9] testQ2 =  [1,8,3,7,4,8,9,6,2,4,6] testQ2S = [1,2,3,4,4,6,6,7,8,8,9] testQ3 = "azfgjidhf" testQ3S = "adffghijz" testQ4 = [] testQ4S = [] testQ5 = [1] testQ5S = [1] testsQ = [testQ1,testQ2,testQ3,testQ4,testQ5] solQ = [testQ1S,testQ2S,testQ3S,testQ4S,testQ5S] testallQuickSort = (map (quickSort) testsQ) == solQ -- Testfaelle fuer Aufgabe 2 -- a) isValid [[0,5,4,3,2,1,0],[5,10,20,30,40,50,1],[4,20,30,40,50,10,2],[3,30,40,50,10,20,2],[2,40,50,10,20,30,2],[1,50,10,20,30,40,2],[0,1,2,2,2,2,0]] == True isValid [[1,5,4,3,2,1,0],[5,10,20,30,40,50,1],[4,20,30,40,50,10,2],[3,30,40,50,10,20,2],[2,40,50,10,20,30,2],[1,50,10,20,30,40,2],[0,1,2,2,2,2,0]] == True isValid [[0,6,4,3,2,1,0],[5,10,20,30,40,50,1],[4,20,30,40,50,10,2],[3,30,40,50,10,20,2],[2,40,50,10,20,30,2],[1,50,10,20,30,40,2],[0,1,2,2,2,2,0]] == False isValid [[0,5,4,3,2,1,0],[5,10,20,30,40,50,1],[4,20,30,40,50,10,2],[3,30,40,50,20,20,2],[2,40,50,10,20,30,2],[1,50,10,20,30,40,2],[0,1,2,2,2,2,0]] == False isValid [[0,5,4,3,2,1,0],[5,10,20,30,40,50,1],[4,20,30,50,10,2],[3,30,40,50,10,20,2],[2,40,50,10,20,30,2],[1,50,10,20,30,40,2],[0,1,2,2,2,2,0]] == False isValid [] == False -- b) -- following helper function compares two skylines compareSkyLine s1 s2 = zipWith id (conv s1) s1 == zipWith id (conv s2) s2 where conv m = [init . tail] ++ (replicate (length m - 2) id) ++ [init . tail] compareSkyLine (compVisibility [[10,20,30,40,50],[20,30,40,50,10],[30,40,50,10,20],[40,50,10,20,30],[50,10,20,30,40]]) ([[0,5,4,3,2,1,0],[5,10,20,30,40,50,1],[4,20,30,40,50,10,2],[3,30,40,50,10,20,2],[2,40,50,10,20,30,2],[1,50,10,20,30,40,2],[0,1,2,2,2,2,0]]) == True compareSkyLine (compVisibility [[10,20,30,40,50],[20,30,40,50,10],[30,40,50,10,20],[40,50,10,20,30],[50,10,20,30,40]]) ([[1,5,4,3,2,1,2],[5,10,20,30,40,50,1],[4,20,30,40,50,10,2],[3,30,40,50,10,20,2],[2,40,50,10,20,30,2],[1,50,10,20,30,40,2],[3,1,2,2,2,2,4]]) == True compareSkyLine (compVisibility [[10,20,30,40,50],[20,30,40,50,10],[30,40,50,10,20],[40,50,10,20,30],[50,10,20,30,40]]) ([[1,5,4,3,2,1,2],[5,10,20,30,40,50,1],[4,20,30,40,50,10,2],[3,30,40,50,10,20,2],[2,40,50,10,20,30,2],[1,50,10,20,30,40,2],[3,1,2,2,3,2,4]]) == False compareSkyLine (compVisibility [[10,20,30,40,50],[20,30,40,50,10],[30,40,50,10,20],[40,50,10,20,30],[50,10,20,30,40]]) ([[1,5,4,3,2,1,2],[5,10,20,30,40,50,1],[4,20,30,40,50,10,2],[3,30,40,50,10,20,2],[2,40,1337,10,20,30,2],[1,50,10,20,30,40,2],[3,1,2,2,2,2,4]]) == False compareSkyLine (compVisibility [[10,20,30,40,50],[20,30,40,50,10],[30,40,50,10,20],[40,50,10,20,30],[50,10,20,30,40]]) ([[5,10,20,30,40,50,1],[4,20,30,40,50,10,2],[3,31,40,50,10,20,2],[2,40,50,10,20,30,2],[1,50,10,20,30,40,2]]) == False -- c) -- do note: proposed solutions might not be unique! buildSkyscrapers [[0,2,1,0],[2,0,0,1],[1,0,0,2],[0,1,2,0]] == Just [[0,2,1,0],[2,10,20,1],[1,20,10,2],[0,1,2,0]] buildSkyscrapers [[0,2,2,0],[2,0,0,1],[1,0,0,2],[0,1,2,0]] == Nothing buildSkyscrapers [[0,5,4,3,2,1,0],[5,0,0,0,0,0,1],[4,0,0,0,0,0,2],[3,0,0,0,0,0,2],[2,0,0,0,0,0,2],[1,0,0,0,0,0,2],[0,1,2,2,2,2,0]] == Just [[0,5,4,3,2,1,0],[5,10,20,30,40,50,1],[4,20,30,40,50,10,2],[3,30,40,50,10,20,2],[2,40,50,10,20,30,2],[1,50,10,20,30,40,2],[0,1,2,2,2,2,0]] buildSkyscrapers [[0,6,4,3,2,1,0],[5,0,0,0,0,0,1],[4,0,0,0,0,0,2],[3,0,0,0,0,0,2],[2,0,0,0,0,0,2],[1,0,0,0,0,0,2],[0,1,2,2,2,2,0]] == Nothing buildSkyscrapers [[0,5,4,3,2,1,0],[5,0,0,0,0,0,1],[4,0,0,0,0,0,2],[3,0,0,0,0,0,2],[2,0,0,0,0,0,2],[1,0,0,0,0,0,2],[0,1,2,2,2,1,0]] == Nothing buildSkyscrapers [[0,5,1,3,2,4,0],[2,0,0,0,0,0,3],[3,0,0,0,0,0,2],[2,0,0,0,0,0,2],[2,0,0,0,0,0,1],[1,0,0,0,0,0,4],[0,1,2,2,2,2,0]] == Just [[0,5,1,3,2,4,0],[2,10,50,30,40,20,3],[3,20,10,40,50,30,2],[2,30,20,50,10,40,2],[2,40,30,10,20,50,1],[1,50,40,20,30,10,4],[0,1,2,2,2,2,0]] -- Weitere Testfaelle fuer Aufgabe 2 skyline1_ok = [[0,3,1,2,2,3,0],[2,30,50,40,20,10,4],[3,10,30,20,50,40,2],[2,20,10,50,40,30,3],[2,40,20,30,10,50,1],[1,50,40,10,30,20,4],[0,1,2,3,3,2,0]] skyline1_ok_start = [[0,3,1,2,2,3,0],[2,0,0,0,0,0,4],[3,0,0,0,0,0,2],[2,0,0,0,0,0,3],[2,0,0,0,0,0,1],[1,0,0,0,0,0,4],[0,1,2,3,3,2,0]] skyline1_ok_novis = [[30,50,40,20,10],[10,30,20,50,40],[20,10,50,40,30],[40,20,30,10,50],[50,40,10,30,20]] skyline2_ok = [[0,2,2,3,1,3,0],[2,40,20,10,50,30,2],[1,50,10,40,30,20,4],[2,30,50,20,40,10,3],[3,10,30,50,20,40,2],[3,20,40,30,10,50,1],[0,3,2,2,4,1,0]] skyline2_ok_start = [[0,2,2,3,1,3,0],[2,0,0,0,0,0,2],[1,0,0,0,0,0,4],[2,0,0,0,0,0,3],[3,0,0,0,0,0,2],[3,0,0,0,0,0,1],[0,3,2,2,4,1,0]] skyline2_ok_novis = [[40,20,10,50,30],[50,10,40,30,20],[30,50,20,40,10],[10,30,50,20,40],[20,40,30,10,50]] skyline3_nok_start = [[0,3,1,2,2,3,0],[2,0,0,0,0,0,4],[3,0,0,0,0,0,2],[2,0,0,0,0,0,3],[2,0,0,0,0,0,2],[1,0,0,0,0,0,4],[0,1,2,3,3,2,0]] skyline4_nok_start = [[0,2,2,3,1,3,0],[2,0,0,0,0,0,2],[1,0,0,0,0,0,4],[2,0,0,0,0,0,3],[3,0,0,0,0,0,2],[3,0,0,0,0,0,1],[0,3,2,2,4,2,0]] skyline5_nok_start = [[0,2,2,3,1,3,0],[2,0,0,0,0,0,2],[6,0,0,0,0,0,4],[2,0,0,0,0,0,3],[3,0,0,0,0,0,2],[3,0,0,0,0,0,1],[0,3,2,2,4,2,0]] skyline6_nok = [[0,2,2,3,1,3,0],[2,40,20,10,50,30,3],[1,50,10,40,30,20,4],[2,30,50,20,40,10,3],[3,10,30,50,20,40,2],[3,20,40,30,10,50,1],[0,3,2,2,4,1,0]] skyline7_nok = [[0,2,2,3,1,3,0],[2,40,20,10,50,30,2],[1,50,10,40,30,20,4],[2,30,50,20,40,10,6],[3,10,30,50,20,40,2],[3,20,40,30,10,50,1],[0,3,2,2,4,1,0]] skyline8_nok = [[0,2,2,3,1,3,0],[2,40,20,10,50,30,2],[1,50,10,40,30,20,4],[2,30,50,20,40,10,3],[3,10,30,50,20,60,2],[3,20,40,30,10,50,1],[0,3,2,2,4,1,0]] skyline9_nok = [[0,2,2,3,1,3,0],[2,40,20,10,0,30,2],[1,50,10,40,30,20,4],[2,30,50,20,40,10,3],[3,10,30,50,20,-10,2],[3,20,40,30,10,50,1],[0,3,2,2,4,1,0]] -- a) testsV = [skyline1_ok, skyline2_ok, skyline6_nok, skyline7_nok, skyline8_nok, skyline9_nok] testValid = (map (isValid) testsV) == [True, True, False, False, False, False] -- b) -- following helper function compares two skylines (from hassi) compareSkyLine s1 s2 = zipWith id (conv s1) s1 == zipWith id (conv s2) s2                                         where conv m = [init . tail] ++ (replicate (length m - 2) id) ++ [init . tail]          testsC = [(compareSkyLine (compVisibility skyline1_ok_novis) (skyline1_ok)), (compareSkyLine (compVisibility skyline2_ok_novis) (skyline2_ok))] testComp = (foldl (&&) True (testsC)) -- c) -- soultions inconclusively unique testsB = [skyline1_ok_start, skyline2_ok_start, skyline3_nok_start, skyline4_nok_start, skyline5_nok_start] solutionsB = [(Just skyline1_ok), (Just skyline2_ok), Nothing, Nothing, Nothing] testBuild = (map (buildSkyscrapers) testsB) == solutionsB testallSkylines = testValid && testComp && testBuild