The game itself is played by initially dealing players a hand of 4 cards. You are right that it shouldn't be a constraint, but I guess for the sake of the game rules, I actually specified "A hand of four cards" in the description (Input). Although it is quite vague, I should have mentioned it more explicitly.
Why is every test case always with 4 cards? I don't see this constraint being mentioned anywhere and it seems that it shouldn't be a constraint in the first place.
I kneel.
exactly
Yeah, it's really cool.
I keep practicing because I know I can think this way too, it just takes practice. You only have to believe!
(It'll be easier once I stop getting bamboozled by parser combinators, arrows, lenses and the like, whew!)
The game itself is played by initially dealing players a hand of 4 cards. You are right that it shouldn't be a constraint, but I guess for the sake of the game rules, I actually specified "A hand of four cards" in the description (Input). Although it is quite vague, I should have mentioned it more explicitly.
This comment is hidden because it contains spoiler information about the solution
Why is every test case always with 4 cards? I don't see this constraint being mentioned anywhere and it seems that it shouldn't be a constraint in the first place.
good point, thank you for the feedback!
You're halfway there with the
Monoid Ordering
!Note that
Bool
is also anOrd
(True > False
), and you can useisDigit
andisUpper
to do the sorting in one expression.Ruby translation.
super fun! what a nice warm-up to algorithms.
i mean, it's a relatively fast solution
still can't get over how smart this solution is
StandaloneDeriving
can do it, nice.https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#stand-alone-deriving-declarations
Hmmm, I'm not sure because the suits don't really come in order, like there is no suit that is higher than another.
Can you derive other instances for a
Suit
datatype? At leastOrd
.Loading more items...