Solving coin problems: Difference between revisions

→‎{{header|Perl}}: step 1: limit to problems involving coins & bills, discard comments, move to DATA handle
m (→‎{{header|Phix}}: (go=>full 28))
(→‎{{header|Perl}}: step 1: limit to problems involving coins & bills, discard comments, move to DATA handle)
Line 559:
}
 
while (<DATA>) {
chomp; # chop trailing newline
my $orig = $_;
Line 767:
print "\n\n";
}
 
</lang>
__DATA__
The following is an example '''input''' file:
<pre>
# Bluman, Allan G. Math word problems demystified. 2005. The McGraw-Hill Companies Inc. p. 112, problem 1
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.
 
# Ibid., p. 112, problem 2
A pile of 18 coins consists of pennies and nickels. If the total amount of the coins is 38¢, find the number of pennies and nickels.
 
# Ibid., p. 112, problem 3
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.
 
# Ibid., p. 112, problem 4
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.
 
# Ibid., p. 112, problem 5
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.
 
# Ibid., p. 112, problem 6
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.
 
# Ibid., p. 112, problem 7
A person bought 12 stamps consisting of 37¢ stamps and 23¢ stamps. If the cost of the stamps is $3.74, find the number of each type of the stamps purchased.
 
# Ibid., p. 112, problem 8
A dairy store sold a total of 80 ice cream sandwiches and ice cream bars. If the sandwiches cost $0.69 each and the bars cost $0.75 each and the store made $58.08, find the number of each sold.
 
# Ibid., p. 112, problem 9
An office supply store sells college-ruled notebook paper for $1.59 a ream and wide-ruled notebook paper for $2.29 a ream. If a student purchased 9 reams of notebook paper and paid $15.71, how many reams of each type of paper did the student purchase?
 
# Ibid., p. 112, problem 10
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?
 
# Ibid., p. 109
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?
 
# Ibid., p. 110
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?
 
# Ibid., p. 111
A person bought ten greeting cards consisting of birthday cards costing $1.50 each and anniversary cards costing $2.00 each. If the total cost of the cards was $17.00, find the number of each kind of card the person bought.
 
# Ibid., p. 119, problem 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.
 
# Ibid., p. 120, problem 9
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.
 
# Ibid., p. 120, problem 10
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.
 
The twenty-six coins in my pocket are all dollar coins and quarters, and they add up to seventeen dollars in value. How many of each coin are there?
# More test problems from around the web...
 
# Source: http://www.purplemath.com/modules/coinprob.htm
# Soln: 12 quarters, 14 dollar coins
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?
 
# Ibid.
# Soln: Then there are six quarters, and I can work backwards to figure out that there are 9 dimes and 18 nickels.
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?
 
# Ibid.
# Soln. There are nine of each type of coin in the wallet.
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?
 
# Source: http://www.algebralab.org/Word/Word.aspx?file=Algebra_CoinProblems.xml
# Soln: Ken has 17 nickels and 8 dimes.
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?
 
# Ibid.
# Let's Practice
# Question #1
# Note: The original question had an inconsistency in it,
# namely "Terry has 7 more" should be "Terry has 2 more..."
# Soln: Terry has 18 dimes and 20 quarters.
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?
 
# Ibid.
# Question #2
# Soln: There are 2 ten-dollar bills, 8 one-dollar bills, and 3 five-dollar bills.
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?
 
# Ibid.
# Try These
# Question #1
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?
 
# Ibid.
# Question #2
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.
 
# Source: http://voices.yahoo.com/how-set-solve-coin-word-problems-algebra-1713709.html
 
# Sample Coin Word Problem 1:
# Soln: Michael has 15 dimes and 12 quarters.
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?
 
# Ibid.
# Sample Coin Word Problem 2:
# Soln: Lucille has 25 quarters and 140 nickels.
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?
 
# Ibid.
# Sample Coin Word Problem 3:
# Soln: Ben has 150 dimes and 121 quarters.
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?
 
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?</lang>
# Source: http://www.calculatorsoup.com/calculators/wordproblems/algebrawordproblem1.php
 
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?
</pre>
And this is the resulting '''output''' file. Each section contains a citation of the source of the input, the original input, the MAXIMA script as formulated by the perl script, and the solution extracted from the MAXIMA output:
<pre>
2,392

edits