Skip to content

Commit

Permalink
Day_07(2023): cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheinxy committed Dec 7, 2023
1 parent c5df9a1 commit 33540e2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions 2023/Day_07/Day_07.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{-# LANGUAGE OverloadedStrings #-}
module Main where

import Data.Function (on)
import Data.List (group, sort)
import Data.Map (Map, (!), fromList)
import Data.Ord (compare)
import Data.Text (replace, unpack, pack)
import Data.Tuple.Extra (both)
import System.Environment

data Hand = Hand { cards :: String, bid :: Int, hType :: Type, order :: String} deriving (Eq, Show)
Expand All @@ -15,8 +15,7 @@ instance Ord Hand where
(Hand c1 _ t1 o1) `compare` (Hand c2 _ t2 o2)
| o1 /= o2 = error "Comparing different games"
| t1 /= t2 = t1 `compare` t2
| otherwise = uncurry (compare `on` (cardStrength !)) .
head . dropWhile (uncurry (==)) $ zip c1 c2
| otherwise = uncurry compare $ both (map (cardStrength !)) (c1, c2)
where cardStrength = fromList $ zip o1 [1 .. ]

type Input = [Hand]
Expand Down

0 comments on commit 33540e2

Please sign in to comment.