projects
/
advent-of-code-19.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
A bit of tidying
[advent-of-code-19.git]
/
advent12
/
src
/
advent12.hs
diff --git
a/advent12/src/advent12.hs
b/advent12/src/advent12.hs
index efd693b8ba578b2b25775a1148e89e845a642d09..043e8d096ce7378bff43d3c66d23a4ff1682e835 100644
(file)
--- a/
advent12/src/advent12.hs
+++ b/
advent12/src/advent12.hs
@@
-46,7
+46,7
@@
main = do
print $ part2 planets
part1 :: Planets (V3 Integer) -> Integer
print $ part2 planets
part1 :: Planets (V3 Integer) -> Integer
-part1
planets = systemEnergy $ head $ drop 1000 $ simulate planets
+part1
= systemEnergy . head . drop 1000 . simulate
part2 :: Planets (V3 Integer) -> Integer
part2 planets = period
part2 :: Planets (V3 Integer) -> Integer
part2 planets = period
@@
-56,16
+56,19
@@
part2 planets = period
enplanet :: (NVec a) => [a] -> Planets a
enplanet :: (NVec a) => [a] -> Planets a
-enplanet = V.fromList . map (\p -> Planet {_pos = p, _vel = nvZero} )
+enplanet = V.fromList . map mkPlanet
+
+mkPlanet :: (NVec a) => a -> Planet a
+mkPlanet p = Planet {_pos = p, _vel = nvZero}
unzipPlanets :: V.Vector (Planet (V3 Integer)) -> [V.Vector (Planet (V1 Integer))]
unzipPlanets :: V.Vector (Planet (V3 Integer)) -> [V.Vector (Planet (V1 Integer))]
-unzipPlanets
planets = dimensionSlice $ V.map unzipPlanet planets
+unzipPlanets
= dimensionSlice . V.map unzipPlanet
unzipPlanet :: Planet (V3 Integer) -> [Planet (V1 Integer)]
unzipPlanet planet = map mkPlanet posVecs
where posVecs = unzipVec $ _pos planet
unzipPlanet :: Planet (V3 Integer) -> [Planet (V1 Integer)]
unzipPlanet planet = map mkPlanet posVecs
where posVecs = unzipVec $ _pos planet
- mkPlanet p = Planet {_pos = p, _vel = nvZero}
+
unzipVec :: V3 Integer -> [V1 Integer]
unzipVec (V3 x y z) = [V1 x, V1 y, V1 z]
unzipVec :: V3 Integer -> [V1 Integer]
unzipVec (V3 x y z) = [V1 x, V1 y, V1 z]