This commit is contained in:
2023-12-13 17:08:51 +01:00
parent 03c18bbe91
commit a307b41ed8
2 changed files with 3 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ getExpansionArray i expOffset expInc (h: t)
getExpansionArrays :: Int -> Image -> (ExpansionArray, ExpansionArray) getExpansionArrays :: Int -> Image -> (ExpansionArray, ExpansionArray)
getExpansionArrays expInc image = let expX = getExpansionArray 1 0 expInc $ sortUniq . map fst $ image getExpansionArrays expInc image = let expX = getExpansionArray 1 0 expInc $ sortUniq . map fst $ image
expY = getExpansionArray 1 0 expInc $ sortUniq . map snd $ image expY = getExpansionArray 1 0 expInc $ sortUniq . map snd $ image
in (listArray (1, length expX) expX, listArray (1, length expY) expY) in (listArray (1, length expX) expX, listArray (1, length expY) expY)
getDistancesGalaxy :: Image -> (ExpansionArray, ExpansionArray) -> (Int, Int) -> [Int] getDistancesGalaxy :: Image -> (ExpansionArray, ExpansionArray) -> (Int, Int) -> [Int]
getDistancesGalaxy [] _ _ = [] getDistancesGalaxy [] _ _ = []

View File

@@ -44,7 +44,7 @@ isLineReflected (y1, x1) (y2, x2) p
isVerticalReflection :: (Int, Int) -> Pattern -> Bool isVerticalReflection :: (Int, Int) -> Pattern -> Bool
isVerticalReflection (y, x) p isVerticalReflection (y, x) p
| y <= fst (snd $ bounds p) = isLineReflected (y, x) (y, x + 1) p && isVerticalReflection (y + 1, x) p | y <= fst (snd $ bounds p) = isLineReflected (y, x) (y, x + 1) p && isVerticalReflection (y + 1, x) p
| otherwise = True | otherwise = True
isColReflected :: (Int, Int) -> (Int, Int) -> Pattern -> Bool isColReflected :: (Int, Int) -> (Int, Int) -> Pattern -> Bool
isColReflected (y1, x1) (y2, x2) p isColReflected (y1, x1) (y2, x2) p
@@ -54,7 +54,7 @@ isColReflected (y1, x1) (y2, x2) p
isHorizontalReflection :: (Int, Int) -> Pattern -> Bool isHorizontalReflection :: (Int, Int) -> Pattern -> Bool
isHorizontalReflection (y, x) p isHorizontalReflection (y, x) p
| x <= snd (snd $ bounds p) = isColReflected (y, x) (y + 1, x) p && isHorizontalReflection (y, x + 1) p | x <= snd (snd $ bounds p) = isColReflected (y, x) (y + 1, x) p && isHorizontalReflection (y, x + 1) p
| otherwise = True | otherwise = True
getVerticalReflection :: Int -> Int -> Pattern -> Int getVerticalReflection :: Int -> Int -> Pattern -> Int
getVerticalReflection x ignore p | x >= snd (snd $ bounds p) = 0 getVerticalReflection x ignore p | x >= snd (snd $ bounds p) = 0