Day eight: Tuple sections :3

This commit is contained in:
2024-12-08 14:03:08 +01:00
parent 3fe54232b2
commit 6f5e886851

View File

@@ -1,3 +1,4 @@
{-# LANGUAGE TupleSections #-}
module Common where module Common where
import Data.Foldable (toList) import Data.Foldable (toList)
@@ -11,7 +12,7 @@ pairPermutations :: [a] -> [(a, a)]
pairPermutations [] = [] pairPermutations [] = []
pairPermutations [_] = [] pairPermutations [_] = []
pairPermutations [x, y] = pure (x, y) pairPermutations [x, y] = pure (x, y)
pairPermutations (x:xs) = map (\y -> (x, y)) xs ++ pairPermutations xs pairPermutations (x:xs) = map (x,) xs ++ pairPermutations xs
type Position = (Int, Int) type Position = (Int, Int)
type Antenna = (Char, Position) type Antenna = (Char, Position)