Skip to content

Instantly share code, notes, and snippets.

@stesla
Created April 2, 2010 17:43
Show Gist options
  • Save stesla/353433 to your computer and use it in GitHub Desktop.
Save stesla/353433 to your computer and use it in GitHub Desktop.
boards :: [Int] -> Int -> [Int]
boards _ 0 = []
boards selection length =
case filter (>= length) selection of
[] -> split selection length
xs -> [minimum xs]
split :: [Int] -> Int -> [Int]
split selection length = smallBoards ++ bigBoards
where max = maximum selection
(quot, rem) = quotRem length max
smallBoards = boards selection rem
bigBoards = replicate quot max
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment