Skip to content

Commit

Permalink
Day_22(2023): faster fix-point detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheinxy committed Dec 22, 2023
1 parent 2cf9adb commit 2f93530
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 2023/Day_22/Day_22.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ removeBricks toRemove = M.map removeSupporting . (`M.withoutKeys` toRemove)

-- Remove a brick and let the chain reaction happen
disintegrate :: Input -> Int -> Input
disintegrate bricks removed = until (\state -> state == removeFalling state) removeFalling startState -- Fix-point iteration
disintegrate bricks removed = until (null . getFalling) removeFalling startState -- Fix-point iteration
where toRemove = S.singleton removed
startState = removeBricks toRemove bricks
removeFalling = removeBricks =<< getFalling
Expand Down

0 comments on commit 2f93530

Please sign in to comment.