Created
October 4, 2020 09:51
-
-
Save ManDeJan/004232fcedad0f172134ca641cdf903a to your computer and use it in GitHub Desktop.
Haskell version with less features and same performance
This file contains 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
{-# LANGUAGE TupleSections #-} | |
pop = | |
[ ("Hard Labor", [1, 2, 3, 4]) | |
, ("Lasting Consequences", [1, 2, 3]) | |
, ("Convenience Fee", [1, 2]) | |
, ("Jury Summons", [1, 2, 3]) | |
, ("Extreme Measures", [1, 3, 6, 10]) | |
, ("Calisthenics Program", [1, 2]) | |
, ("Benefits Package", [2, 5]) | |
, ("Middle Management", [1, 2]) | |
, ("Underworld Customs", [1, 2]) | |
, ("Forced Overtime", [2, 4, 6]) | |
, ("Heightened Security", [1]) | |
, ("Routine Inspection", [2, 4, 6, 8]) | |
, ("Damage Control", [1, 2]) | |
, ("Approval Process", [2, 5]) | |
, ("Tight Deadline", [2, 5]) ] | |
heat = 5 | |
withZero = zip (fst <$> pop) $ (0:) . snd <$> pop | |
toOptions = (\(n, h) -> (n,) <$> h) <$> withZero | |
allPacts = sequence toOptions | |
pactsFiltered = filter ((heat ==) . sum . map snd) allPacts | |
main = print $ pactsFiltered !! 4 -- 4 is a random number. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment