cleanup
This commit is contained in:
		
							parent
							
								
									149ba84b98
								
							
						
					
					
						commit
						46a6c20cde
					
				|  | @ -20,7 +20,7 @@ solveA :: [(Int,Int)] -> Fold -> Int | ||||||
| solveA dots f = length $ nub $ map (crease f) dots | solveA dots f = length $ nub $ map (crease f) dots | ||||||
| 
 | 
 | ||||||
| solveB :: [(Int,Int)] -> [Fold] -> [String] | solveB :: [(Int,Int)] -> [Fold] -> [String] | ||||||
| solveB dots fs = showPaper $ foldl (\d f -> map (crease f) d) dots fs | solveB dots folds = showPaper $ (foldl (\d f -> map (crease f) d)) dots folds | ||||||
| 
 | 
 | ||||||
| crease :: Fold -> (Int,Int) -> (Int,Int) | crease :: Fold -> (Int,Int) -> (Int,Int) | ||||||
| crease (Hori h) (x,y) = | crease (Hori h) (x,y) = | ||||||
|  | @ -33,23 +33,21 @@ crease (Vert v) (x,y) = | ||||||
|   else (x, (v-(y-v))) |   else (x, (v-(y-v))) | ||||||
| 
 | 
 | ||||||
| parseFolds :: [String] -> [Fold] | parseFolds :: [String] -> [Fold] | ||||||
| parseFolds ss = map f ss | parseFolds = map f | ||||||
|   where |   where | ||||||
|     g (d:'=':t) = (if d == 'y' then Vert else Hori) (read t) |     g (d:'=':t) = (if d == 'y' then Vert else Hori) (read t) | ||||||
|     f s = g (drop 11 s) |     f = g . (drop 11) | ||||||
| 
 | 
 | ||||||
| parseDots :: [String] -> [(Int,Int)] | parseDots :: [String] -> [(Int,Int)] | ||||||
| parseDots ss = map f ss | parseDots = map f | ||||||
|   where |   where | ||||||
|     g (x:y:_) = ((read x), (read y)) |     g (x:y:_) = ((read x), (read y)) | ||||||
|     f s = g $ words $ map (\c -> if c == ',' then ' ' else c) s |     f s = g $ words $ map (\c -> if c == ',' then ' ' else c) s | ||||||
| 
 | 
 | ||||||
| showPaper :: [(Int,Int)] -> [String] | showPaper :: [(Int,Int)] -> [String] | ||||||
| showPaper db = mkPap | showPaper db = map (\y -> mkRow y) [0..mH] | ||||||
|   where |   where | ||||||
|     mW = maximum $ map fst $ db |     mW = maximum $ map fst $ db | ||||||
|     mH = maximum $ map snd $ db |     mH = maximum $ map snd $ db | ||||||
|     f c = if c then '#' else ' ' |     f c = if c then '▉' else ' ' | ||||||
|     mkRow y = [ f $ (x,y) `elem` db | x <- [0..mW] ] |     mkRow y = [ f $ (x,y) `elem` db | x <- [0..mW] ] | ||||||
|     mkPap = map (\y -> mkRow y) [0..mH] |  | ||||||
| 
 |  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 thornAvery
						thornAvery