Skip to content

Commit

Permalink
fiddle
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Dec 14, 2024
1 parent 8438457 commit 1a32578
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion solutions/solutions.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions solutions/src/2024/14.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 1a32578

Please sign in to comment.