Created
March 10, 2021 19:22
-
-
Save guibou/ce98dc4d8e7b7c39b86c9dabd679955e to your computer and use it in GitHub Desktop.
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
| {-# OPTIONS -Wall #-} | |
| queueTime :: [Int] -> Int -> Int | |
| queueTime l n = go (take n l) (drop n l) 0 | |
| where | |
| go [] [] res = res | |
| go workers remains res = let | |
| faster = minimum workers | |
| workers' = filter(/= 0) $ map (subtract faster) workers | |
| l' = workers' ++ remains | |
| in go (take n l') (drop n l') (res + faster) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment