McNuggets problem: Difference between revisions

→‎{{header|Haskell}}: Simplified with (\\) (difference) function
(→‎{{header|Haskell}}: Added a Haskell draft)
(→‎{{header|Haskell}}: Simplified with (\\) (difference) function)
Line 89:
 
=={{header|Haskell}}==
<lang haskell>import Data.List (nub, sortBy(\\), uncons)
import Data.Ord (comparing)
 
nuggets :: [Int]
nuggets =
(\\) [100,99 .. 1] $
nub $
sortBy (flip (comparing id)) $
[0 .. quot 100 6] >>=
\x ->
Line 105 ⟶ 104:
in [ v
| 101 > v ]
 
mbMax :: Maybe ((Int, Int), [(Int, Int)])
mbMax = uncons $ filter (uncurry (/=)) $ zip [100,99 ..] nuggets
 
main :: IO ()
main =
print $
case mbMaxuncons nuggets of
Just ((x, _), _) -> show x
Nothing -> "No unreachable quantities found ..."</lang>
<pre>43</pre>
9,659

edits