let score category (dice:Die list) =
    let iDice = dice |> List.map int |> List.sortDescending
    let diced = iDice |> List.countBy id |> List.sortByDescending snd
    let countScore cat = dice |> List.filter (fun d -> d=cat) |> List.length |> (*) (int cat)
    let isStraight = iDice.[0] - iDice.[4] = 4

    match category  , List.map snd diced  with
    | Yacht         , [5]         -> 50
    | Ones          , _           -> countScore Die.One
    | Twos          , _           -> countScore Die.Two
    | Threes        , _           -> countScore Die.Three
    | Fours         , _           -> countScore Die.Four
    | Fives         , _           -> countScore Die.Five
    | Sixes         , _           -> countScore Die.Six
    | FourOfAKind   , [4;1]
    | FourOfAKind   , [5]         -> iDice |> List.head |> (*) 4
    | LittleStraight, [1;1;1;1;1] when isStraight && iDice.[0] = 5 -> 30
    | BigStraight   , [1;1;1;1;1] when isStraight && iDice.[0] = 6 -> 30
    | FullHouse     , [3;2]
    | Choice        , _           -> iDice |> List.sum
    | _             , _           -> 0

----------------------------------------------------

[
	["keyword", "let"],
	" score category ",
	["punctuation", "("],
	"dice",
	["punctuation", ":"],
	["class-name", ["Die"]],
	" list",
	["punctuation", ")"],
	["operator", "="],

	["keyword", "let"],
	" iDice ",
	["operator", "="],
	" dice ",
	["operator", "|>"],
	" List",
	["punctuation", "."],
	"map int ",
	["operator", "|>"],
	" List",
	["punctuation", "."],
	"sortDescending\r\n    ",

	["keyword", "let"],
	" diced ",
	["operator", "="],
	" iDice ",
	["operator", "|>"],
	" List",
	["punctuation", "."],
	"countBy id ",
	["operator", "|>"],
	" List",
	["punctuation", "."],
	"sortByDescending snd\r\n    ",

	["keyword", "let"],
	" countScore cat ",
	["operator", "="],
	" dice ",
	["operator", "|>"],
	" List",
	["punctuation", "."],
	"filter ",
	["punctuation", "("],
	["keyword", "fun"],
	" d ",
	["operator", "->"],
	" d",
	["operator", "="],
	"cat",
	["punctuation", ")"],
	["operator", "|>"],
	" List",
	["punctuation", "."],
	"length ",
	["operator", "|>"],
	["punctuation", "("],
	["operator", "*"],
	["punctuation", ")"],
	["punctuation", "("],
	"int cat",
	["punctuation", ")"],

	["keyword", "let"],
	" isStraight ",
	["operator", "="],
	" iDice",
	["punctuation", "."],
	["punctuation", "["],
	["number", "0"],
	["punctuation", "]"],
	["operator", "-"],
	" iDice",
	["punctuation", "."],
	["punctuation", "["],
	["number", "4"],
	["punctuation", "]"],
	["operator", "="],
	["number", "4"],

	["keyword", "match"],
	" category  ",
	["punctuation", ","],
	" List",
	["punctuation", "."],
	"map snd diced  ",
	["keyword", "with"],

	["operator", "|"],
	" Yacht         ",
	["punctuation", ","],
	["punctuation", "["],
	["number", "5"],
	["punctuation", "]"],
	["operator", "->"],
	["number", "50"],

	["operator", "|"],
	" Ones          ",
	["punctuation", ","],
	" _           ",
	["operator", "->"],
	" countScore Die",
	["punctuation", "."],
	"One\r\n    ",

	["operator", "|"],
	" Twos          ",
	["punctuation", ","],
	" _           ",
	["operator", "->"],
	" countScore Die",
	["punctuation", "."],
	"Two\r\n    ",

	["operator", "|"],
	" Threes        ",
	["punctuation", ","],
	" _           ",
	["operator", "->"],
	" countScore Die",
	["punctuation", "."],
	"Three\r\n    ",

	["operator", "|"],
	" Fours         ",
	["punctuation", ","],
	" _           ",
	["operator", "->"],
	" countScore Die",
	["punctuation", "."],
	"Four\r\n    ",

	["operator", "|"],
	" Fives         ",
	["punctuation", ","],
	" _           ",
	["operator", "->"],
	" countScore Die",
	["punctuation", "."],
	"Five\r\n    ",

	["operator", "|"],
	" Sixes         ",
	["punctuation", ","],
	" _           ",
	["operator", "->"],
	" countScore Die",
	["punctuation", "."],
	"Six\r\n    ",

	["operator", "|"],
	" FourOfAKind   ",
	["punctuation", ","],
	["punctuation", "["],
	["number", "4"],
	["punctuation", ";"],
	["number", "1"],
	["punctuation", "]"],

	["operator", "|"],
	" FourOfAKind   ",
	["punctuation", ","],
	["punctuation", "["],
	["number", "5"],
	["punctuation", "]"],
	["operator", "->"],
	" iDice ",
	["operator", "|>"],
	" List",
	["punctuation", "."],
	"head ",
	["operator", "|>"],
	["punctuation", "("],
	["operator", "*"],
	["punctuation", ")"],
	["number", "4"],

	["operator", "|"],
	" LittleStraight",
	["punctuation", ","],
	["punctuation", "["],
	["number", "1"],
	["punctuation", ";"],
	["number", "1"],
	["punctuation", ";"],
	["number", "1"],
	["punctuation", ";"],
	["number", "1"],
	["punctuation", ";"],
	["number", "1"],
	["punctuation", "]"],
	["keyword", "when"],
	" isStraight ",
	["operator", "&&"],
	" iDice",
	["punctuation", "."],
	["punctuation", "["],
	["number", "0"],
	["punctuation", "]"],
	["operator", "="],
	["number", "5"],
	["operator", "->"],
	["number", "30"],

	["operator", "|"],
	" BigStraight   ",
	["punctuation", ","],
	["punctuation", "["],
	["number", "1"],
	["punctuation", ";"],
	["number", "1"],
	["punctuation", ";"],
	["number", "1"],
	["punctuation", ";"],
	["number", "1"],
	["punctuation", ";"],
	["number", "1"],
	["punctuation", "]"],
	["keyword", "when"],
	" isStraight ",
	["operator", "&&"],
	" iDice",
	["punctuation", "."],
	["punctuation", "["],
	["number", "0"],
	["punctuation", "]"],
	["operator", "="],
	["number", "6"],
	["operator", "->"],
	["number", "30"],

	["operator", "|"],
	" FullHouse     ",
	["punctuation", ","],
	["punctuation", "["],
	["number", "3"],
	["punctuation", ";"],
	["number", "2"],
	["punctuation", "]"],

	["operator", "|"],
	" Choice        ",
	["punctuation", ","],
	" _           ",
	["operator", "->"],
	" iDice ",
	["operator", "|>"],
	" List",
	["punctuation", "."],
	"sum\r\n    ",

	["operator", "|"],
	" _             ",
	["punctuation", ","],
	" _           ",
	["operator", "->"],
	["number", "0"]
]