Skip to content

Commit

Permalink
Allow more than ^ for 06
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Dec 11, 2024
1 parent f6f3fb7 commit 1706f61
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions solutions/src/2024/06.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# Language ViewPatterns #-}
{-|
Module : Main
Description : Day 6 solution
Expand Down Expand Up @@ -31,7 +32,7 @@ loop.
module Main (main) where

import Advent (getInputArray, countBy, ordNub)
import Advent.Coord (Coord, north, turnRight)
import Advent.Coord (Coord, north, turnRight, charToVec)
import Data.Array.Unboxed (UArray, (//), (!?), assocs, amap)

-- | >>> :main
Expand All @@ -40,10 +41,10 @@ import Data.Array.Unboxed (UArray, (//), (!?), assocs, amap)
main :: IO ()
main =
do input <- getInputArray 2024 6
let start = head [p | (p, '^') <- assocs input]
let (dir, start) = head [(dir, p) | (p, charToVec -> Just dir) <- assocs input]
walls = amap ('#' ==) input
path1 = ordNub (map snd (walk walls north start))
check2 p = isLoop (walk (walls // [(p, True)]) north start)
path1 = ordNub (map snd (walk walls dir start))
check2 p = isLoop (walk (walls // [(p, True)]) dir start)
print (length path1)
print (countBy check2 (drop 1 path1))

Expand Down

0 comments on commit 1706f61

Please sign in to comment.