Skip to content

Commit

Permalink
inline
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Dec 13, 2023
1 parent 3c65aba commit f2b6275
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions solutions/src/2023/13.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ findReflection target xs =
[ i
| (i,l,r) <- zip3 [0..] (inits xs) (tails xs)
, not (null l), not (null r)
, target == sum (zipWith (\x y -> sum (zipWith val x y)) (reverse l) r)
, let val x y = if x == y then 0 else 1
, let differences x y = sum (zipWith val x y)
, target == sum (zipWith differences (reverse l) r)
]

solver :: Int -> [String] -> [Int]
solver target xs = findReflection target (transpose xs)
++ map (100*) (findReflection target xs)

val :: Char -> Char -> Int
val x y = if x == y then 0 else 1

0 comments on commit f2b6275

Please sign in to comment.