Department numbers: Difference between revisions

Content deleted Content added
Util (talk | contribs)
→‎{{header|Perl 6}}: Added Perl 6 solution
Hout (talk | contribs)
→‎{{header|Haskell}}: Generalising a little more, to allow for experimentation ( bureaucracy grows )
Line 66:
 
=={{header|Haskell}}==
<lang Haskell>options :: Int -> Int -> Int -> [(Int, Int, Int)]
options lo hi total =
let ds = [1lo .. 7hi]
in [2,filter 4,even 6]ds >>=
\x ->
ds >>=
\y ->
if x /= y
then let z = 12total - (x + y)
in [ (yx, xy, z)
| y /= z && elemz >= lo && z ds<= hi ]
else []
 
-- TEST -----------------------------------------------------------------------
main :: IO ()
main = do
mapM_let printxs = options 1 7 12
mapM_ putStrLn ["\nNumber(Police, of options: "Sanitation, show (length optionsFire)]</lang>\n"
mapM_ print xs
mapM_ putStrLn ["\nNumber of options: ", show (length xs)]
</lang>
{{Out}}
<pre>(3Police,2 Sanitation,7 Fire)
 
(4,2,6)
(6,2,43,7)
(7,2,3)
(1,4,7)
(2,4,6)
(3,4,5)
(5,4,3)
(6,4,2)
(7,4,1)
(1,6,5)
(2,6,4)
(52,47,3)
(4,1,7)
(4,2,6)
(7,4,13,5)
(74,25,3)
(4,6,2)
(54,67,1)
(36,41,5)
(1,6,52,4)
(16,4,72)
(6,45,21)
 
Number of options: