A 2023/07.example => 2023/07.example +5 -0
@@ 0,0 1,5 @@
+32T3K 765
+T55J5 684
+KK677 28
+KTJJT 220
+QQQJA 483
A 2023/07.hs => 2023/07.hs +51 -0
@@ 0,0 1,51 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE NamedFieldPuns #-}
+{-# LANGUAGE NoImplicitPrelude #-}
+module Main where
+
+import Qulude
+
+--import Data.Array ( (!) )
+import qualified Data.Array as Array
+import qualified Data.Array.ST as STArray
+import qualified Data.Either as Either
+import qualified Data.List as List
+--import Data.Map ( (!) )
+import qualified Data.Map as Map
+import qualified Data.Maybe as Maybe
+import qualified Data.Sequence as Seq
+import qualified Data.Set as Set
+
+data Card = Ace | King | Queen | Jack | Joker | Num Int
+ deriving ( Show, Eq )
+type Hand = [Card]
+
+type Parse = [(Hand, Int)]
+parser :: Parser Parse
+parser = many $ do
+ hand <- many cardP
+ spaces
+ bid <- int
+ spaces
+ return (hand, bid)
+ where cardP = (char 'A' $> Ace)
+ <|> (char 'K' $> King)
+ <|> (char 'Q' $> King)
+ <|> (char 'T' $> Jack)
+ <|> (char 'J' $> Joker)
+ <|> (digit <&> Num . read . flip (:) [])
+
+partA :: Parse -> Parse
+partA = id
+
+--partB :: Parse -> Parse
+--partB = id
+
+main :: IO ()
+main = with parser $ do
+ run "07.example" "a example" partA
+ run "07.input" "a input" partA
+ --run "07.example" "b example" partB
+ --run "07.input" "b input" partB