Skip to content
This repository has been archived by the owner on Nov 17, 2024. It is now read-only.

Commit

Permalink
streamline day 13 more
Browse files Browse the repository at this point in the history
  • Loading branch information
mstksg committed Dec 13, 2023
1 parent 25f9518 commit 8e84018
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/AOC/Challenge/Day13.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Data.IntMap (IntMap)
import qualified Data.IntMap as IM
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import Data.List (find)
import Data.List.Split (splitOn)
import Data.Maybe (listToMaybe)
import Data.Set (Set)
Expand Down Expand Up @@ -61,8 +62,10 @@ day13a =

findSmudge :: Set Point -> Maybe Int
findSmudge pts = flip firstJust (fillBoundingBox' pts) \pt ->
let newRefl = IS.fromList $ findRefl (over (contains pt) not pts)
in fst <$> IS.minView (newRefl `IS.difference` origRefl)
find (`IS.notMember` origRefl)
. findRefl
. over (contains pt) not
$ pts
where
origRefl = IS.fromList $ findRefl pts

Expand Down

0 comments on commit 8e84018

Please sign in to comment.