diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2019-12-11 11:56:18 +0100 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2019-12-11 11:57:12 +0100 |
commit | 1405a7fe6ce05a75bb36bcee3c7d19cc296a6de0 (patch) | |
tree | 074648ccc60d929b3110bceb0706fe4fcf781698 /2019 | |
parent | df7a8ac54e22baaaf47bbddaee3eff74e2730905 (diff) |
Day 10
Diffstat (limited to '2019')
-rw-r--r-- | 2019/10.hs | 22 |
1 files changed, 3 insertions, 19 deletions
@@ -22,22 +22,11 @@ main = do pts = [(a + i * dx, b + i * dy) | i <- [1..g-1]] in all (not . (arr !)) pts numVisible p = length (filter (\q -> q /= p && sight p q) asts) - -- (cent@(centx, centy), centNumVis) = maximumBy (comparing snd) (zip asts (map numVisible asts)) - (cent@(centx, centy), centNumVis) = ((8, 3), 42) + (cent@(centx, centy), centNumVis) = maximumBy (comparing snd) (zip asts (map numVisible asts)) print centNumVis - print cent - - let -- atan2R' dy dx - -- | dy <= 0, dx < 0 = abs dy % abs dx : -inf -> 0 - -- | dy > 0, dx < 0 = abs dy % abs dx : 0 -> inf - -- | dy > 0, dx == 0 = 0 - -- | dy > 0, dx > 0 = abs dy % abs dx : inf -> 0 - -- | dy <= 0, dx > 0 = abs dy % abs dx : 0 -> -inf - -- | dy < 0, dx == 0 = 1 - -- | otherwise = undefined -- (dx, dy) == (0, 0) - threeLine (cx, cy) (a, b) (x, y) = (a - cx) * (y - cy) == (x - cx) * (b - cy) + let threeLine (cx, cy) (a, b) (x, y) = (a - cx) * (y - cy) == (x - cx) * (b - cy) distsq (a, b) (x, y) = (x - a) * (x - a) + (y - b) * (y - b) otherAsts = sortOn (\(x, y) -> atan2 (fromIntegral (centx - x) :: Double) (fromIntegral (y - centy))) (filter (/= cent) asts) @@ -46,9 +35,4 @@ main = do zapRound l = (map head l, filter (not . null) (map tail l)) zapped = concat (takeWhile (not . null) (map fst (tail (iterate (zapRound . snd) (undefined, groups))))) - mapM_ print groups - print zapped - print (zapped !! 199) - - -- let (n200x, n200y) = otherAsts !! 199 - -- print (n200x * 100 + n200y) + print (let (x, y) = zapped !! 199 in 100 * x + y) |