More fixes or somehting like that
This commit is contained in:
parent
4f73ff3c56
commit
4af44ebd0b
13
day10.hs
13
day10.hs
|
@ -1,5 +1,4 @@
|
||||||
import Data.List as List
|
import Data.List as List
|
||||||
import Debug.Trace as Trace
|
|
||||||
|
|
||||||
|
|
||||||
main = do
|
main = do
|
||||||
|
@ -7,11 +6,13 @@ main = do
|
||||||
let layers = lines content
|
let layers = lines content
|
||||||
let indexlayers = map(\x-> mapInd(\x y -> (y,x)) x ) layers
|
let indexlayers = map(\x-> mapInd(\x y -> (y,x)) x ) layers
|
||||||
let points = concat (mapInd(\x y->map(\x->((fst x,y),snd x))x) $ indexlayers)
|
let points = concat (mapInd(\x y->map(\x->((fst x,y),snd x))x) $ indexlayers)
|
||||||
let asteroids = (Trace.traceShowId(map fst (filter(\(x,y) -> y == '#' ) points)))
|
let asteroids = (map fst (filter(\(x,y) -> y == '#' ) points))
|
||||||
let changedAsteroids = changeCoordinate asteroids (2,2)
|
let changedAsteroids = changeCoordinate asteroids (2,2)
|
||||||
--let sortedAsteroids = sortBy sortDistance asteroids
|
--let sortedAsteroids = sortBy sortDistance asteroids
|
||||||
--let view = length (getViews (asteroids) (3,4))
|
--let view = length (getViews (asteroids) (3,4))
|
||||||
--let result = List.maximum(map(\x-> length(getViews (asteroids) x)) (asteroids))
|
let maximum = List.maximum(map(\x-> length(getViews (asteroids) x)) (asteroids))
|
||||||
|
let station = head $ map(\x-> fst x) $ filter(\x-> snd x == maximum )(map(\x-> (x,( length(getViews (asteroids) x)))) (asteroids))
|
||||||
|
|
||||||
let views = (getViews asteroids (2,2))
|
let views = (getViews asteroids (2,2))
|
||||||
let lines = map reduce(map(\(x,y)-> ((x-2),(y-2))) (getBorder (2,2) 4))
|
let lines = map reduce(map(\(x,y)-> ((x-2),(y-2))) (getBorder (2,2) 4))
|
||||||
let order = destroyOrders changedAsteroids lines (2,2) []
|
let order = destroyOrders changedAsteroids lines (2,2) []
|
||||||
|
@ -20,6 +21,8 @@ main = do
|
||||||
--mapM putStrLn (map(\(x,y)->(show x ) ++(show y)) sortedAsteroids)
|
--mapM putStrLn (map(\(x,y)->(show x ) ++(show y)) sortedAsteroids)
|
||||||
-- putStrLn ( show result)
|
-- putStrLn ( show result)
|
||||||
--mapM putStrLn ( map show views)
|
--mapM putStrLn ( map show views)
|
||||||
|
putStrLn (show maximum)
|
||||||
|
putStrLn (show station)
|
||||||
mapM putStrLn ( map show order)
|
mapM putStrLn ( map show order)
|
||||||
--mapM putStrLn (map show (layers))
|
--mapM putStrLn (map show (layers))
|
||||||
--mapM putStrLn ( map show destroyed)
|
--mapM putStrLn ( map show destroyed)
|
||||||
|
@ -28,9 +31,9 @@ destroyOrders :: [(Int,Int)] ->[(Int,Int)] -> (Int,Int) -> [(Int,Int)] -> [(Int
|
||||||
destroyOrders ast laser station out
|
destroyOrders ast laser station out
|
||||||
|length ast > 0 = do
|
|length ast > 0 = do
|
||||||
let views = foldl getView [] ast
|
let views = foldl getView [] ast
|
||||||
let destroyed = (Trace.traceShowId(destroyOrder views laser []))
|
let destroyed = (destroyOrder views laser [])
|
||||||
let newout = out ++ destroyed
|
let newout = out ++ destroyed
|
||||||
let newast = (Trace.traceShowId(ast \\ destroyed))
|
let newast = (ast \\ destroyed)
|
||||||
destroyOrders newast laser station newout
|
destroyOrders newast laser station newout
|
||||||
|otherwise = out
|
|otherwise = out
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user