Question: coin problem brainteaser

silver_coin_braintea.mw

Experts. This is something like the subset sum problem with a twist.

Jane has some Australian silver coins in her pocket. When buying an apple, she
realises she has more than $1 in silver coins, but can’t make exactly $1 with
her coins. How is this possible? (Silver Australian coins come in 5c, 10c, 20c,
and 50c.)

answer: obviously, you can't have more than one 50c piece; no more than four
20c; no 10c, and only one 5c. This adds up to 135c

its fairly easy to understand the answer, but its less easy to write code to get that answer.you have to maximize the value, but the subset sum cannot equal 100. my attempt doesnt work

Please Wait...