Solving coin problems: Difference between revisions

(Added Go)
Line 978:
solve([total = n_dime * v_dime + n_penny * v_penny, count = n_dime + n_penny], [n_dime, n_penny]);
solution: n_dime = 2, n_penny = 10
</pre>
 
=={{header|Phix}}==
The title of this task is solving <i>coin</i> problems, therefore I have ruthlessly eradicated stamps, sandwiches, paper, and cards.
It just adds unnecessary fiddling, along with the need to add custom assets and asset-values, such as 37c stamps, $1.50 cards, etc.
Hence this covers 24/28 of the Perl examples (and 14/18 of Go). On the plus side, there is no hard limit on the number of unknowns,
though all examples below are for 2 and 3 only. A couple (14 and 17) also sail perilously close to getting a divide by zero.
This task was quite a bit of fun, once I got stuck in.
<lang Phix>-- demo\rosetta\Solving_coin_problems.exw
constant source = """
If a person has three times as many quarters as dimes and the total amount of money is $5.95, find the number of quarters and dimes.
--==>expected:quarters = 21, dimes = 7
A pile of 18 coins consists of pennies and nickels. If the total amount of the coins is 38c, find the number of pennies and nickels.
--==>expected:pennies = 13, nickels = 5
A small child has 6 more quarters than nickels. If the total amount of coins is $3.00, find the number of nickels and quarters the child has.
--==>expected:quarters = 11, nickels = 5
A child's bank contains 32 coins consisting of nickels and quarters. If the total amount of money is $3.80, find the number of nickels and quarters in the bank.
--==>expected:nickels = 21, quarters = 11
A person has twice as many dimes as she has pennies and three more nickels than pennies. If the total amount of the coins is $1.97, find the numbers of each type of coin the person has.
--==>expected:dimes = 14, pennies = 7, nickels = 10
In a bank, there are three times as many quarters as half dollars and 6 more dimes than half dollars. If the total amount of the money in the bank is $4.65, find the number of each type of coin in the bank.
--==>expected:quarters = 9, half_dollars = 3, dimes = 9
A clerk is given $75 in bills to put in a cash drawer at the start of a workday. There are twice as many $1 bills as $5 bills and one less $10 bill than $5 bills. How many of each type of bill are there?
--==>expected:one_dollar_bills = 10, five_dollar_bills = 5, ten_dollar_bills = 4
A person has 8 coins consisting of quarters and dimes. If the total amount of this change is $1.25, how many of each kind of coin are there?
--==>expected:quarters = 3, dimes = 5
A person has 3 times as many dimes as he has nickels and 5 more pennies than nickels. If the total amount of these coins is $1.13, how many of each kind of coin does he have?
--==>expected:dimes = 9, nickels = 3, pennies = 8
A person has 9 more dimes than nickels. If the total amount of money is $1.20, find the number of dimes the person has.
--==>expected:dimes = 11, nickels = 2
A person has 20 bills consisting of $1 bills and $2 bills. If the total amount of money the person has is $35, find the number of $2 bills the person has.
--==>expected:one_dollar_bills = 5, two_dollar_bills = 15
A bank contains 8 more pennies than nickels and 3 more dimes than nickels. If the total amount of money in the bank is $3.10, find the number of dimes in the bank.
--==>expected:pennies = 25, nickels = 17, dimes = 20
Your uncle walks in, jingling the coins in his pocket. He grins at you and tells you that you can have all the coins if you can figure out how many of each kind of coin he is carrying. You're not too interested until he tells you that he's been collecting those gold-tone one-dollar coins. The twenty-six coins in his pocket are all dollars and quarters, and they add up to seventeen dollars in value. How many of each coin does he have?
--==>expected:dollars = 14, quarters = 12
A collection of 33 coins, consisting of nickels, dimes, and quarters, has a value of $3.30. If there are three times as many nickels as quarters, and one-half as many dimes as nickels, how many coins of each kind are there?
--==>expected:nickels = 18, dimes = 9, quarters = 6
A wallet contains the same number of pennies, nickels, and dimes. The coins total $1.44. How many of each type of coin does the wallet contain?
--==>expected:pennies = 9, nickels = 9, dimes = 9
Suppose Ken has 25 coins in nickels and dimes only and has a total of $1.65. How many of each coin does he have?
--==>expected:nickels = 17, dimes = 8
Terry has 2 more quarters than dimes and has a total of $6.80. The number of quarters and dimes is 38. How many quarters and dimes does Terry have?
--==>expected:quarters = 20, dimes = 18
In my wallet, I have one-dollar bills, five-dollar bills, and ten-dollar bills. The total amount in my wallet is $43. I have four times as many one-dollar bills as ten-dollar bills. All together, there are 13 bills in my wallet. How many of each bill do I have?
--==>expected:one_dollar_bills = 8, five_dollar_bills = 3, ten_dollar_bills = 2
Marsha has three times as many one-dollar bills as she does five dollar bills. She has a total of $32. How many of each bill does she have?
--==>expected:one_dollar_bills = 12, five_dollar_bills = 4
A vending machine has $41.25 in it. There are 255 coins total and the machine only accepts nickels, dimes and quarters. There are twice as many dimes as nickels. How many of each coin are in the machine.
--==>expected:nickels = 45, dimes = 90, quarters = 120
Michael had 27 coins in all, valuing $4.50. If he had only quarters and dimes, how many coins of each kind did he have?
--==>expected:quarters = 12, dimes = 15
Lucille had $13.25 in nickels and quarters. If she had 165 coins in all, how many of each type of coin did she have?
--==>expected:nickels = 140, quarters = 25
Ben has $45.25 in quarters and dimes. If he has 29 less quarters than dimes, how many of each type of coin does he have?
--==>expected:quarters = 121, dimes = 150
A person has 12 coins consisting of dimes and pennies. If the total amount of money is $0.30, how many of each coin are there?
--==>expected:dimes = 2, pennies = 10""",
 
{texts,replacements} = columnize({{"."," ."},
{","," ,"},
{"had","has"},
{"contain?","have?"},
{"there?","have?"},
{"has .","have?"},
{"in the bank .","have?"},
{"in the machine .","have?"},
{"as many","asmany"},
{" , and they add up"," . total"},
{" , has a value"," . total"},
{" only and has a total"," . total"},
{" and has a total"," . total"},
{"All together ,","total"},
{"A vending machine has","total"},
{"valuing","total"},
{"coins in all ,","coins ."},
{"coins total and","coins ."},
{"find","many"},
{"consists","consisting"},
{"twenty-six","26"},
{"seventeen dollars in value","$17.00"},
{" one "," 1 "},
{"three","3"},
{"four","4"},
{"twice","2 times"},
{"ten","10"},
{" and the total"," . total"},
{"half dollars","half_dollars"},
{"$1 bills","one_dollar_bills"},
{"$2 bills","two_dollar_bills"},
{"$5 bills","five_dollar_bills"},
{"$10 bill","ten_dollar_bills"},
{"one-dollar bills","one_dollar_bills"},
{"five-dollar bills","five_dollar_bills"},
{"five dollar bills","five_dollar_bills"},
{"10-dollar bills","ten_dollar_bills"},
{"10_dollar_bills","ten_dollar_bills"}}),
 
noise = split("the|a|to|of|i|is|that|it|on|you|this|for|but|with|are|have|be|at|or|was|so|if|out|not|he|she|they|has|do|does"&
"|in|these|person|small|child|child's|bank|pile|clerk|given|put|there|cash|drawer|start|workday|his|suppose|ken"&
"|terry|how|my|marsha|machine|accepts|michael|lucille|ben|number|type|kind|amount|collection|contains|change"&
"|wallet|did|numbers|pocket","|"),
 
-- one spectacularly irksome preamble containing absolutely no useful information whatsoever...:
uncle = "your uncle walks in , jingling the coins in his pocket . "&
"he grins at you and tells you that you can have all the coins "&
"if you can figure out how many of each kind of coin he is carrying . "&
"you're not too interested until he tells you that he's been collecting "&
"those gold-tone one-dollar coins . ",
 
vocab = {"times","asmany","quarters","as","dimes","and","total","money","many","have?",
"coins","consisting","pennies","nickels","more","less","than","each","coin",
"half_dollars","bills","bill","all","dollars","one-half","same","only",
"one_dollar_bills","two_dollar_bills","five_dollar_bills","ten_dollar_bills"},
 
{assets,assetv} = columnize({{"ten_dollar_bills",1000},
{"five_dollar_bills",500},
{"two_dollar_bills",200},
{"one_dollar_bills",100},
{"dollars",100},
{"half_dollars",50},
{"quarters",25},
{"dimes",10},
{"nickels",5},
{"pennies",1}})
 
integer count = 0
sequence lines = split(substitute_all(source,texts,replacements),"\n"),
expectations = {},
vused = repeat(false,length(vocab)),
words
for i=1 to length(lines) by 2 do
string li = lower(lines[i])
if match("your uncle",li)=1 then
-- note: if you tweak texts/replacements then you may
-- need to tweak the uncle constant to match.
if match(uncle,li)!=1 then ?9/0 end if
li = li[length(uncle)+1..$]
end if
words = split(li,no_empty:=true)
for n=1 to length(noise) do
words = remove_all(noise[n],words)
end for
if words[$]="." and find(words[$-1],{"dimes","nickels"}) then
words[$] = "have?"
end if
if words[1]="," then words = words[2..$] end if
for w=length(words) to 2 by -1 do
-- re-join eg "$3" and ".99" (oops)
if length(words[w])>1 and words[w][1]='.' then
words[w-1..w] = {words[w-1]&words[w]}
end if
end for
words = match_replace({",","many"},words,{".","many"})
words = match_replace({","},words,{})
count += 1
lines[count] = words
li = lines[i+1]
if match("--==>expected:",li)!=1 then ?9/0 end if
li = li[15..$]
li = substitute(li," ,",",")
expectations = append(expectations,li)
end for
lines = lines[1..count]
printf(1,"%d puzzles:\n",count)
printf(1,"Step 1: remove noise and otherwise simplify (if nothing else, down to a %d-word vocab):\n\n",length(vocab))
for i=1 to count do
printf(1,"%d: %s\n",{i,join(lines[i])})
end for
 
function add_unknowns(sequence unknowns, words)
for i=1 to length(words) do
string word = words[i]
if not find(word,unknowns)
and not find(word,{"as","consisting","all","and","than","only"}) then
unknowns = append(unknowns,word)
end if
end for
return unknowns
end function
 
function parse_sentence(sequence words, unknowns)
-- Converts eg {"$1.00","quarters","and","nickels"} to {100,25,5}.
-- An "equation" of {100,25,5} means "100==25*unknown[1]+5*unknown[2]".
-- Obviously this is suitably scruffy, but the 31-word vocab certainly helps!
-- It is worth noting that by this stage most sentences begin or end in a number.
-- Since we may not have the full set of unknowns, each equation ends with a code:
-- 0: pad with 0, 1: pad with 1, 'a': pad with the unknown asset values
sequence sentences = {},
sentence,
rest = {},
isnumber = repeat(0,length(words))
integer k
bool set_asset_sum = false
for w=1 to length(words) do
string ww = words[w]
k = find(ww,vocab)
if k=0 then
sequence r
for f=1 to 3 do
r = scanf(ww,{"%d","%dc","$%f"}[f])
if r!={} then
isnumber[w] = iif(f=3?round(r[1][1]*100):r[1][1])
exit
end if
end for
if r={} then ?ww ?9/0 end if
else
vused[k] = true
end if
end for
if isnumber[1] then
if words[2]="times" then
if words[3]!="asmany" then ?9/0 end if
k = find("and",words)
if k then
rest = words[k+1..$]
words = words[1..k-1]
end if
-- eg {"3","times","asmany","quarters","as","dimes"}
if length(words)!=6 or words[5]!="as" then ?9/0 end if
unknowns = add_unknowns(unknowns, words[4..6])
sentence = repeat(0,length(unknowns)+1)
k = find(words[4],unknowns)
sentence[k+1] = 1
k = find(words[6],unknowns)
sentence[k+1] = -isnumber[1]
sentence &= 0
sentences = append(sentences,sentence)
elsif words[2]="coins"
or (words[2]="bills" and length(words)>2) then
--/* eg:
{"18","coins","consisting","pennies","and","nickels"}
{"26","coins","all","dollars","and","quarters"}
{"25","coins","nickels","and","dimes"}
{"33","coins","consisting","nickels","dimes","and","quarters"}
{"27","coins"}
{"20","bills","consisting","one_dollar_bills","and","two_dollar_bills"}
--*/
unknowns = add_unknowns(unknowns, words[3..$])
sentence = {isnumber[1]}&repeat(1,length(unknowns))
sentence &= 1
sentences = append(sentences,sentence)
elsif find(words[2],{"more","less"}) then
k = find("and",words)
if k then
rest = words[k+1..$]
words = words[1..k-1]
end if
--/* eg:
{"5","more","pennies","than","nickels"}
{"29","less","quarters","than","dimes"}
--*/
if length(words)!=5 or words[4]!="than" then ?9/0 end if
unknowns = add_unknowns(unknowns, words[3..$])
sentence = {isnumber[1]}&repeat(0,length(unknowns))
integer less = iff(words[2]="less"?-1:+1)
k = find(words[3],unknowns)
sentence[k+1] = less
k = find(words[5],unknowns)
sentence[k+1] = -less
sentence &= 0
sentences = append(sentences,sentence)
else
--/* eg:
{"$75","bills"}
{"$45.25","quarters","and","dimes"}
--*/
if length(words)>2 then
-- log assets:
-- eg {"$13.25","nickels","and","quarters"}
if words[3]!="and" or length(words)!=4 then ?9/0 end if
unknowns = add_unknowns(unknowns, words[2..$])
end if
sentence = {isnumber[1]}
set_asset_sum = true
end if
elsif isnumber[$] then
if words[1]="total"
or (length(words)=3 and words[1..2]={"coins","total"}) then
--/*
{"total","money","$5.95"}
{"total","coins","38c"}
{"total","coins","$3.00"}
{"total","$3.74"}
{"total","cost","$17.00"}
{"coins","total","$1.44"}
--*/
sentence = {isnumber[$]}
set_asset_sum = true
else
-- eg {"quarters","and","dimes","38"}
unknowns = add_unknowns(unknowns, words[1..$-1])
sentence = {isnumber[$]}&repeat(1,length(unknowns))
sentence &= 1
sentences = append(sentences,sentence)
end if
elsif words[1]="one-half" then
-- eg {"one-half","asmany","dimes","as","nickels"}
if length(words)!=5 or words[2]!="asmany" or words[4]!="as" then ?9/0 end if
unknowns = add_unknowns(unknowns, words[3..$])
sentence = repeat(0,length(unknowns)+1)
k = find(words[3],unknowns)
sentence[k+1] = -2
k = find(words[5],unknowns)
sentence[k+1] = 1
sentence &= 0
sentences = append(sentences,sentence)
elsif words[1]="many" then
--/* eg
{"many","quarters","and","dimes","have?"}
{"many","each","coin","have?"}
{"many","each","have?"}
{"many","each","bill","have?"}
{"many","dimes","have?"}
{"many","coins","each","have?"}
--*/
if words[$]!="have?" then ?9/0 end if
-- no rule, as yet, just outputs everything instead.
elsif words[1]="same" then
-- eg {"same","pennies","nickels","and","dimes"}
unknowns = add_unknowns(unknowns, words[2..$])
if length(unknowns)!=3 then ?9/0 end if
sentences = append(sentences,{0,1,-1,0,0}) -- (p==n)
sentences = append(sentences,{0,0,1,-1,0}) -- (n==d)
elsif words[1]="total" then
-- eg {"total","13","bills"}
if length(words)!=3 or not isnumber[2] or words[3]!="bills" then ?9/0 end if
sentence = {isnumber[2]}&repeat(1,length(unknowns))
sentence &= 1
sentences = append(sentences,sentence)
else
--/* eg:
{"one_dollar_bills","five_dollar_bills","and","ten_dollar_bills"}
{"only","nickels","dimes","and","quarters"}
{"only","quarters","and","dimes"}
--*/
-- just log assets:
unknowns = add_unknowns(unknowns, words)
end if
if set_asset_sum then
-- common code for eg {"total","$3.74"} and {"$75","bills"}
for u=1 to length(unknowns) do
string uu = unknowns[u]
k = find(uu,assets)
sentence &= assetv[k]
end for
sentence &= 'a'
sentences = append(sentences,sentence)
end if
if length(rest) then
{sequence s2,unknowns} = parse_sentence(rest,unknowns)
sentences &= s2
end if
return {sentences,unknowns}
end function
 
procedure solveN(integer n, sequence rules, unknowns, string expected)
--
-- Based on https://mathcs.clarku.edu/~djoyce/ma105/simultaneous.html
-- aka the ancient Chinese Jiuzhang suanshu ~100 B.C. (!!)
--
string res
sequence sentences = rules, ri, rj
integer l = length(rules), rii, rji, i, j
for i=1 to l do
-- successively eliminate (grow lower left triangle of 0s)
ri = rules[i]
if length(ri)!=l+1 then ?9/0 end if
rii = ri[i+1]
if rii=0 then ?9/0 end if
for j=i+1 to l do
rj = rules[j]
rji = rj[i+1]
if rji!=0 then
rj = sq_sub(sq_mul(rj,rii),sq_mul(ri,rji))
if rj[i+1]!=0 then ?9/0 end if -- (job done)
rules[j] = rj
end if
end for
end for
for i=l to 1 by -1 do
-- then substitute each backwards
ri = rules[i]
rii = ri[1]/ri[i+1] -- (all else should be 0)
rules[i] = sprintf("%s = %d",{unknowns[i],rii})
for j=i-1 to 1 by -1 do
rj = rules[j]
rji = rj[i+1]
if rji!=0 then
rj[1] -= rji*rii
rj[i+1] = 0
rules[j] = rj
end if
end for
end for
res = join(rules,", ")
printf(1,"%d: %v ==> %s\n",{n,sentences,res})
-- printf(1,"%d: %s\n",{n,res}) -- (maybe pref.)
if res!=expected then ?9/0 end if
end procedure
 
printf(1,"\nStep 2: convert sentences into structures/equations, and solve them:\n")
for i=1 to count do
words = split(lines[i],{"."})
sequence sentences = {},
sentencii, -- (one ...but some still contain "and")
unknowns = {}
for w=1 to length(words) do
{sentencii,unknowns} = parse_sentence(words[w],unknowns)
sentences &= sentencii
end for
if length(sentences)>length(unknowns) then
-- messy: puzzle has too much info!
-- (14 aka "33 coins" and 17 "Terry" with 38 coins,
-- eliminate wrongly and get a divide by zero...)
-- sentences = sentences[1..length(unknowns)]
sentences[-2] = sentences[-1]
sentences = sentences[1..length(unknowns)]
end if
if length(sentences)!=length(unknowns) then ?9/0 end if
for s=1 to length(sentences) do
-- pad any short equations, eg 3 more nickels than dimes
-- needs a 0 for quarters, if were not mentioned before.
sequence ss = sentences[s]
integer pad = ss[$]
ss = ss[1..$-1]
integer short = length(sentences)+1-length(ss)
if short then
switch pad do
case 0: ss &= repeat(0,short)
case 1: ss &= repeat(1,short)
case 'a':
for u=-short to -1 do
string uu = unknowns[u]
integer k = find(uu,assets)
ss &= assetv[k]
end for
default: ?9/0
end switch
end if
sentences[s] = ss
end for
solveN(i,sentences,unknowns,expectations[i])
end for
 
integer k = find(false,vused)
if k then ?{"unused vocab",vocab[k]} end if</lang>
The problem numbering system used below is mine alone.<br>
I was slightly unsure whether to interpolate these q&a outputs, but I think the separation chosen has its own merits.<br>
The structures/equations of part 2 are completely unreadable at first, but quite simple really.
{{out}}
<pre>
24 puzzles:
Step 1: remove noise and otherwise simplify (if nothing else, down to a 31-word vocab):
 
1: 3 times asmany quarters as dimes . total money $5.95 . many quarters and dimes have?
2: 18 coins consisting pennies and nickels . total coins 38c . many pennies and nickels have?
3: 6 more quarters than nickels . total coins $3.00 . many nickels and quarters have?
4: 32 coins consisting nickels and quarters . total money $3.80 . many nickels and quarters have?
5: 2 times asmany dimes as pennies and 3 more nickels than pennies . total coins $1.97 . many each coin have?
6: 3 times asmany quarters as half_dollars and 6 more dimes than half_dollars . total money $4.65 . many each coin have?
7: $75 bills . 2 times asmany one_dollar_bills as five_dollar_bills and 1 less ten_dollar_bills than five_dollar_bills . many each bill have?
8: 8 coins consisting quarters and dimes . total $1.25 . many each coin have?
9: 3 times asmany dimes as nickels and 5 more pennies than nickels . total coins $1.13 . many each coin have?
10: 9 more dimes than nickels . total money $1.20 . many dimes have?
11: 20 bills consisting one_dollar_bills and two_dollar_bills . total money $35 . many two_dollar_bills have?
12: 8 more pennies than nickels and 3 more dimes than nickels . total money $3.10 . many dimes have?
13: 26 coins all dollars and quarters . total $17.00 . many each coin have?
14: 33 coins consisting nickels dimes and quarters . total $3.30 . 3 times asmany nickels as quarters and one-half asmany dimes as nickels . many coins each have?
15: same pennies nickels and dimes . coins total $1.44 . many each coin have?
16: 25 coins nickels and dimes . total $1.65 . many each coin have?
17: 2 more quarters than dimes . total $6.80 . quarters and dimes 38 . many quarters and dimes have?
18: one_dollar_bills five_dollar_bills and ten_dollar_bills . total $43 . 4 times asmany one_dollar_bills as ten_dollar_bills . total 13 bills . many each bill have?
19: 3 times asmany one_dollar_bills as five_dollar_bills . total $32 . many each bill have?
20: total $41.25 . 255 coins . only nickels dimes and quarters . 2 times asmany dimes as nickels . many each coin have?
21: 27 coins . total $4.50 . only quarters and dimes . many coins each have?
22: $13.25 nickels and quarters . 165 coins . many each coin have?
23: $45.25 quarters and dimes . 29 less quarters than dimes . many each coin have?
24: 12 coins consisting dimes and pennies . total money $0.30 . many each coin have?
 
Step 2: convert sentences into structures/equations, and solve them:
1: {{0,1,-3},{595,25,10}} ==> quarters = 21, dimes = 7
2: {{18,1,1},{38,1,5}} ==> pennies = 13, nickels = 5
3: {{6,1,-1},{300,25,5}} ==> quarters = 11, nickels = 5
4: {{32,1,1},{380,5,25}} ==> nickels = 21, quarters = 11
5: {{0,1,-2,0},{3,0,-1,1},{197,10,1,5}} ==> dimes = 14, pennies = 7, nickels = 10
6: {{0,1,-3,0},{6,0,-1,1},{465,25,50,10}} ==> quarters = 9, half_dollars = 3, dimes = 9
7: {{7500,100,500,1000},{0,1,-2,0},{1,0,1,-1}} ==> one_dollar_bills = 10, five_dollar_bills = 5, ten_dollar_bills = 4
8: {{8,1,1},{125,25,10}} ==> quarters = 3, dimes = 5
9: {{0,1,-3,0},{5,0,-1,1},{113,10,5,1}} ==> dimes = 9, nickels = 3, pennies = 8
10: {{9,1,-1},{120,10,5}} ==> dimes = 11, nickels = 2
11: {{20,1,1},{3500,100,200}} ==> one_dollar_bills = 5, two_dollar_bills = 15
12: {{8,1,-1,0},{3,0,-1,1},{310,1,5,10}} ==> pennies = 25, nickels = 17, dimes = 20
13: {{26,1,1},{1700,100,25}} ==> dollars = 14, quarters = 12
14: {{33,1,1,1},{330,5,10,25},{0,1,-2,0}} ==> nickels = 18, dimes = 9, quarters = 6
15: {{0,1,-1,0},{0,0,1,-1},{144,1,5,10}} ==> pennies = 9, nickels = 9, dimes = 9
16: {{25,1,1},{165,5,10}} ==> nickels = 17, dimes = 8
17: {{2,1,-1},{38,1,1}} ==> quarters = 20, dimes = 18
18: {{4300,100,500,1000},{0,1,0,-4},{13,1,1,1}} ==> one_dollar_bills = 8, five_dollar_bills = 3, ten_dollar_bills = 2
19: {{0,1,-3},{3200,100,500}} ==> one_dollar_bills = 12, five_dollar_bills = 4
20: {{4125,5,10,25},{255,1,1,1},{0,-2,1,0}} ==> nickels = 45, dimes = 90, quarters = 120
21: {{27,1,1},{450,25,10}} ==> quarters = 12, dimes = 15
22: {{1325,5,25},{165,1,1}} ==> nickels = 140, quarters = 25
23: {{4525,25,10},{29,-1,1}} ==> quarters = 121, dimes = 150
24: {{12,1,1},{30,10,1}} ==> dimes = 2, pennies = 10
</pre>
 
7,805

edits