Day 22
This commit is contained in:
23
day22/Part2.hs
Normal file
23
day22/Part2.hs
Normal file
@@ -0,0 +1,23 @@
|
||||
module Part2 where
|
||||
|
||||
import Commons
|
||||
import qualified Data.Map.Strict as M
|
||||
import qualified Data.Set as S
|
||||
import Data.Foldable (maximumBy)
|
||||
import Data.Function (on)
|
||||
|
||||
|
||||
getFutureFall' :: Snapshot -> S.Set Brick -> S.Set Brick
|
||||
getFutureFall' s sFell =
|
||||
let falling = getFalling s
|
||||
in if null falling then sFell
|
||||
else let fell = getFell s falling
|
||||
newSFell = S.union (S.difference sFell (S.fromList $ map snd falling)) $ S.fromList $ map snd fell
|
||||
in getFutureFall' (getPostFall s falling fell) newSFell
|
||||
|
||||
getFutureFall :: Snapshot -> Brick -> S.Set Brick
|
||||
getFutureFall s b = let newSnapshot = M.difference s $ M.fromList $ map (\ c -> ((z c, y c, x c), b)) b
|
||||
in getFutureFall' newSnapshot S.empty
|
||||
|
||||
getReactions :: Snapshot -> [S.Set Brick]
|
||||
getReactions s = S.toList $ S.fromList $ map (getFutureFall s) $ M.elems s
|
||||
Reference in New Issue
Block a user