Day10: Part2 works
This commit is contained in:
parent
7b28a5a035
commit
c4fce9b29e
11
day10.hs
11
day10.hs
|
@ -17,10 +17,11 @@ main = do
|
||||||
let destroyNormal = map (\(a,b)-> (((fst station) + a),((snd station) + b))) destroyed
|
let destroyNormal = map (\(a,b)-> (((fst station) + a),((snd station) + b))) destroyed
|
||||||
putStrLn(show maximum)
|
putStrLn(show maximum)
|
||||||
putStrLn(show station)
|
putStrLn(show station)
|
||||||
putStrLn(show views)
|
putStrLn(show views)
|
||||||
putStrLn(show sortedViews)
|
putStrLn(show sortedViews)
|
||||||
putStrLn(show $ map degree destroyed)
|
putStrLn(show $ map degree destroyed)
|
||||||
putStrLn(show $ destroyNormal!!19)
|
putStrLn(show $ destroyNormal)
|
||||||
|
putStrLn(show $ destroyNormal!!199)
|
||||||
mapInd :: (a -> Int -> b) -> [a] -> [b]
|
mapInd :: (a -> Int -> b) -> [a] -> [b]
|
||||||
mapInd f l = zipWith f l [0..]
|
mapInd f l = zipWith f l [0..]
|
||||||
|
|
||||||
|
@ -40,8 +41,8 @@ sortDistance ((a,b)) ((a2,b2))
|
||||||
| abs(a) + abs(b) == abs(a2) + abs(b2) = EQ
|
| abs(a) + abs(b) == abs(a2) + abs(b2) = EQ
|
||||||
|
|
||||||
sortDegree a b
|
sortDegree a b
|
||||||
| degree a > degree b = GT
|
| degree a < degree b = GT
|
||||||
| degree a < degree b = LT
|
| degree a > degree b = LT
|
||||||
| degree a == degree b = EQ
|
| degree a == degree b = EQ
|
||||||
|
|
||||||
getViews :: [(Int,Int)] -> [(Int,Int)]
|
getViews :: [(Int,Int)] -> [(Int,Int)]
|
||||||
|
@ -62,4 +63,4 @@ degree :: (Int,Int) -> Double
|
||||||
degree (a,b) = do
|
degree (a,b) = do
|
||||||
let x = fromIntegral a
|
let x = fromIntegral a
|
||||||
let y = fromIntegral b
|
let y = fromIntegral b
|
||||||
y / x
|
atan2 x (y)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user