Find minimum number of coins that make a given value: Difference between revisions
Find minimum number of coins that make a given value (view source)
Revision as of 05:43, 12 August 2021
, 2 years ago→{{header|Haskell}}: Case where smallest denomination leaves an unsummed residue
m (→{{header|Haskell}}: Case where smallest denomination leaves an unsummed residue) |
|||
Line 117:
change :: [Int] -> Int -> Either String [(Int, Int)]
change units n
|
| otherwise =
Left $
concat
[ "Residue of ",
show (mod n m),
" - no denomination smaller than ",
show m,
"."
]
where
m = minimum units
go _ 0 = []
go (x : xs) n
Line 144 ⟶ 153:
qvs
)
(change [200, 100, 50, 20, 10, 5
{{Out}}
<pre>Summing to 1024:
|