Created
November 11, 2020 16:51
-
-
Save FredrikAugust/6c9dc4d3c8b7fe8af19c3d4b3ef87468 to your computer and use it in GitHub Desktop.
Maximum possible score in first row of Yahtzee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Yahtzee where | |
import Data.List (group, maximumBy, sortBy) | |
yahtzee_upper :: [Int] -> Int | |
yahtzee_upper numbers = | |
sum | |
. maximumBy (\x x' -> compare (sum x) (sum x')) | |
. group | |
. sortBy (compare) | |
$ numbers | |
main :: IO () | |
main = | |
print $ yahtzee_upper [4, 5, 4, 3, 3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment