From 1a325781f0c306d456158ca0b13bd9ab09444fe9 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Sat, 14 Dec 2024 12:23:54 -0800 Subject: [PATCH] fiddle --- solutions/solutions.cabal | 2 +- solutions/src/2024/14.hs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/solutions/solutions.cabal b/solutions/solutions.cabal index a41efdb..d13a621 100644 --- a/solutions/solutions.cabal +++ b/solutions/solutions.cabal @@ -1104,7 +1104,7 @@ executable sln_2023_23 executable sln_2023_24 import: day main-is: 2023/24.hs - build-depends: hmatrix, sbv ^>= 11 + build-depends: hmatrix, sbv executable sln_2023_25 import: day diff --git a/solutions/src/2024/14.hs b/solutions/src/2024/14.hs index 13b2180..7a8e053 100644 --- a/solutions/src/2024/14.hs +++ b/solutions/src/2024/14.hs @@ -17,7 +17,7 @@ committing it into the repo. module Main where import Advent (counts, format) -import Advent.Coord (Coord(C), drawCoords, zipCoord) +import Advent.Coord (Coord(C), drawCoords, mapCoord, zipCoord) room :: Coord room = C 103 101 @@ -30,13 +30,13 @@ main = toQuad :: Coord -> [Int] toQuad (C y x) - | x < roomX `div` 2, y < roomY `div` 2 = [1] - | x > roomX `div` 2, y < roomY `div` 2 = [2] - | x < roomX `div` 2, y > roomY `div` 2 = [3] - | x > roomX `div` 2, y > roomY `div` 2 = [4] - | otherwise = [] + | x < midX, y < midY = [1] + | x > midX, y < midY = [2] + | x < midX, y > midY = [3] + | x > midX, y > midY = [4] + | otherwise = [] where - C roomY roomX = room + C midY midX = mapCoord (`div` 2) room step :: Int -> (Int, Int, Int, Int) -> Coord step n (x, y, dx, dy) = zipCoord mod (C (y + n * dy) (x + n * dx)) room