Skip to content

Instantly share code, notes, and snippets.

@FredrikAugust
Created November 11, 2020 16:51
Show Gist options
  • Save FredrikAugust/6c9dc4d3c8b7fe8af19c3d4b3ef87468 to your computer and use it in GitHub Desktop.
Save FredrikAugust/6c9dc4d3c8b7fe8af19c3d4b3ef87468 to your computer and use it in GitHub Desktop.
Maximum possible score in first row of Yahtzee
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