projects
/
advent-of-code-19.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ae0a0b8
)
Now using Double, not Float
author
Neil Smith
<neil.git@njae.me.uk>
Thu, 12 Dec 2019 08:28:38 +0000
(08:28 +0000)
committer
Neil Smith
<neil.git@njae.me.uk>
Thu, 12 Dec 2019 08:28:38 +0000
(08:28 +0000)
advent10/src/advent10.hs
patch
|
blob
|
history
diff --git
a/advent10/src/advent10.hs
b/advent10/src/advent10.hs
index ba90ba1429788b160e2b4aaaa95eeb7b03075b7f..376f66757c195708df0658e4591901d8f19b9497 100644
(file)
--- a/
advent10/src/advent10.hs
+++ b/
advent10/src/advent10.hs
@@
-12,7
+12,7
@@
type Position = V2 Rational
type Asteroids = S.Set Position
type Asteroids = S.Set Position
-type TargetInfo = (
Float, Float
)
+type TargetInfo = (
Double, Double
)
type Targets = M.Map TargetInfo Position
main :: IO ()
type Targets = M.Map TargetInfo Position
main :: IO ()
@@
-76,7
+76,7
@@
targetInfo origin target = (angle, range)
targetSequence :: Targets -> [Position]
targetSequence targets = targetNext ((- pi / 2) - 0.001) targets
targetSequence :: Targets -> [Position]
targetSequence targets = targetNext ((- pi / 2) - 0.001) targets
-targetNext ::
Float
-> Targets -> [Position]
+targetNext ::
Double
-> Targets -> [Position]
targetNext angle targets
| M.null targets = []
| M.null possibles = targetNext (- pi) targets
targetNext angle targets
| M.null targets = []
| M.null possibles = targetNext (- pi) targets
@@
-86,7
+86,7
@@
targetNext angle targets
targets' = M.delete (targetAngle, targetRange) targets
angle' = targetAngle
targets' = M.delete (targetAngle, targetRange) targets
angle' = targetAngle
-possibleTargets ::
Float
-> Targets -> Targets
+possibleTargets ::
Double
-> Targets -> Targets
possibleTargets angle targets = M.filterWithKey (\(a, _) _ -> a > angle) targets
firstTarget :: Targets -> (TargetInfo, Position)
possibleTargets angle targets = M.filterWithKey (\(a, _) _ -> a > angle) targets
firstTarget :: Targets -> (TargetInfo, Position)