Skip to content

Commit

Permalink
faster
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Dec 7, 2023
1 parent 27c0bf8 commit bd6fa57
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions solutions/src/2023/07.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ strength1 hand = category hand : map val hand
val x = fromJust (x `elemIndex` "23456789TJQKA")

strength2 :: String -> [Int]
strength2 a = maximum [category xs : map val a | xs <- traverse rpl a]
strength2 a = maximum [category (map rpl a) : map val a
| alt <- "23456789TQKA"
, let rpl x = if x == 'J' then alt else x
]
where
rpl 'J' = "23456789TQKA"
rpl x = [x]

val x = fromJust (x `elemIndex` "J23456789TQKA")
val x = fromJust (x `elemIndex` "J23456789TQKA")

category :: String -> Int
category m =
Expand Down

0 comments on commit bd6fa57

Please sign in to comment.