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 | ||||
| 
 | ||||
| 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 (Hori h) (x,y) = | ||||
|  | @ -33,23 +33,21 @@ crease (Vert v) (x,y) = | |||
|   else (x, (v-(y-v))) | ||||
| 
 | ||||
| parseFolds :: [String] -> [Fold] | ||||
| parseFolds ss = map f ss | ||||
| parseFolds = map f | ||||
|   where | ||||
|     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 ss = map f ss | ||||
| parseDots = map f | ||||
|   where | ||||
|     g (x:y:_) = ((read x), (read y)) | ||||
|     f s = g $ words $ map (\c -> if c == ',' then ' ' else c) s | ||||
| 
 | ||||
| showPaper :: [(Int,Int)] -> [String] | ||||
| showPaper db = mkPap | ||||
| showPaper db = map (\y -> mkRow y) [0..mH] | ||||
|   where | ||||
|     mW = maximum $ map fst $ 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] ] | ||||
|     mkPap = map (\y -> mkRow y) [0..mH] | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 thornAvery
						thornAvery