Skip to content

Commit

Permalink
drop the pattern, too verbose.
Browse files Browse the repository at this point in the history
  • Loading branch information
Javran committed Jan 7, 2024
1 parent 85daf85 commit 18c628d
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/Javran/AdventOfCode/Y2023/Day2.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE PatternSynonyms #-}

module Javran.AdventOfCode.Y2023.Day2 () where

import Data.Monoid hiding (First, Last)
Expand Down Expand Up @@ -35,15 +33,10 @@ gameLineP = do
strP ": "
(n,) <$> oneSetP `sepBy1` strP "; "

{-
It would be neat if this sort of thing can be put in some general library instead of us having to
declare it here - which makes it a bit more too verbose to my liking.
-}
pattern MaxRgb :: a -> a -> a -> (Max a, Max a, Max a)
pattern MaxRgb r g b = (Max r, Max g, Max b)

findPower :: GameLine -> Int
findPower = (\(MaxRgb r g b) -> r * g * b) . foldMap (\(Rgb (r, g, b)) -> MaxRgb r g b)
findPower =
(\(Max r, Max g, Max b) -> r * g * b)
. foldMap (\(Rgb (r, g, b)) -> (Max r, Max g, Max b))

instance Solution Day2 where
solutionSolved _ = True
Expand Down

0 comments on commit 18c628d

Please sign in to comment.