hindent
This commit is contained in:
parent
5ab4cd7856
commit
8a8721bb26
|
@ -1,11 +1,13 @@
|
|||
import qualified Data.Map as M
|
||||
import Data.List.Split
|
||||
import Control.Arrow
|
||||
import Control.Monad
|
||||
import Data.List.Split
|
||||
import qualified Data.Map as M
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
input <- map (map read . filter (/="->")) <$> map (splitOneOf ", ") <$> lines <$> readFile "input"
|
||||
input <-
|
||||
map (map read . filter (/= "->")) <$> map (splitOneOf ", ") <$> lines <$>
|
||||
readFile "input"
|
||||
let process = length . M.filter (> 1) . M.fromListWith (+) . toMap
|
||||
print $ join (***) process $ (filterOrth input, input)
|
||||
|
||||
|
@ -21,7 +23,8 @@ toMap ([x1,y1,x2,y2]:xs)
|
|||
| y1 == y2 = zip ySame (repeat 1) ++ toMap xs
|
||||
| x1 == x2 = zip xSame (repeat 1) ++ toMap xs
|
||||
| otherwise = zip diag (repeat 1) ++ toMap xs
|
||||
where diag = zip xRange yRange
|
||||
where
|
||||
diag = zip xRange yRange
|
||||
ySame = zip xRange (repeat y1)
|
||||
xSame = zip (repeat x1) yRange
|
||||
xRange = [x1,x1 - (signum $ x1 - x2) .. x2]
|
||||
|
|
Loading…
Reference in New Issue
Block a user