Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module X where
- type Cell = Char
- type Table = [[Cell]]
- type ClueLine = [Int]
- type Clues = ([ClueLine],[ClueLine])
- unknown = 'u'
- empty = 'e'
- full = 'f'
- duckClues = (duckRows,duckCols) :: Clues
- poundClues = (poundRows,poundCols) :: Clues
- duckRows = [[3], [5], [4,3], [7], [5], [3], [5], [1,8],
- [3,3,3], [7,3,2], [5,4,2], [8,2], [10], [2,3], [6]]
- duckCols = [[3], [4], [5], [4], [5], [6], [3,2,1], [2,2,5],
- [4,2,6], [8,2,3], [8,2,1,1], [2,6,2,1], [4,6], [2,4], [1]]
- poundRows = [[4], [2,1], [1,2], [2,2], [2], [8], [2], [8],
- [2], [2], [2,2,2], [6,3], [2,5,3], [2,2,6], [4,4]]
- poundCols = [[2],[4],[2,1],[1,1,2,1],[1,1,4],[11],[12],
- [2,1,1,2],[1,1,1,3],[1,1,1,2],[1,1,1,2],[3,3],[2,3],[3],[2]]
- -- MEGOLDASOK INNEN
- showCell :: Cell -> Char
- showCell 'f' = '#'
- showCell 'e' = ' '
- showCell 'u' = '?'
- showCell _ = '0'
- showRow :: [Cell] -> String
- showRow [] = "||\n"
- showRow row = "|"++[showCell c | c <- row]++"|\n"
- showTable :: Table -> String
- showTable [] = []
- showTable tbl = concat [showRow row | row <- tbl]
- emptyLineOptions :: ClueLine -> Int -> [[Cell]]
- emptyLineOptions [clue] n =
- [(replicate i 'e')++(replicate clue 'f')++(replicate (n-i-clue) 'e' )| i <- [0..n-clue]] -- egy clue JO
- emptyLineOptions clues n
- | and [null clues, n<0] =
- [] -- nincs clue, neg sor JO
- | and [null clues, n>=0] =
- [replicate n 'e'] -- nincs clue, nemneg sor JO
- | (sum clues) > n =
- []
- | n > (sum clues + (length clues-1)) =
- concat [emptyLineOptions [c] ((sum clues)-c) | c <- clues] -- van clue, nincs hely
- | otherwise =
- [] -- sok clue, van hely
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement