Jump to content
  • Advertisement
Sign in to follow this  
ph33r

Simple Elementry school problem made difficult.

This topic is 5110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My girlfriend is getting her degree in education, and has to take elementry math so she can be able to teach it. When I heard she had to take elementry math and she complained to me the problems were hard I made fun of her. Though, the jokes on me because I can't figure it out either. The series of problems generalized is you have n amount of coins and M amount of money. How many nickels, dimes, quaters, and pennies do you need to get M. So an example of a question was if you had 25c and 3 coins how many n,d,q, and p's would you have? I tried solving a general form of an equation but my system of equations are always under-determined. That is.
25x + 10y + 5z + 1w = 25
x + y + z + w = 3
or
[25 10 5  1 ]  [x] [25]
[1  1  1  1 ]  [y] [3]
[a1 a2 a3 a4]* [z]=[u1]
[b1 b2 b3 b4]  [w] [u2]

There are 2 equations and four unkowns so the system is underdetermined. The constraint that you have so many coins to add up to so much money leads me to believe there is only one answer and since there is only one answer to the problem there must be a way to solve the problem mathematically not algorithmically. And it bothers me very much that I can't figure it out. -Dave

Share this post


Link to post
Share on other sites
Advertisement
[EDIT: just realized i missed the constraint of 3 coins... oops :)]

you don't solve this with a system of equations, that's why it's "elementary math". there are many possible answers. you can have all pennies, or just pennies and nickles, etc. you solve it by iterative modulus operations. maybe someone can come up with some equations to solve, but this is the easy way (and how you'd teach 6yr olds to do it, albeit not in code :))


//amount passed as amount of cents
void howMany( int amount )
{
int numQuarters = 0, numDimes = 0;
int numNickles = 0, numPennies = 0;

numQuarters = amount % 25;
amount -= numQuarters * 25;

if ( amount > 0 )
{
numDimes = amount % 10;
amount -= numDimes * 10;

if ( amount > 0 )
{
numNickles = amount % 5;
amount -= numNickles * 5;

if ( amount > 0 )
numPennies = amount;
}
}
}





Share this post


Link to post
Share on other sites
This reminds me of that study where phd students from an ivy league school scored worse than highschool feshman on the same test.

the moral was that the phd guys tried answering the questions using calculus, and the freshmen jsut used formulas they learned in geometery. the phd students made more mistakes.

the constraints you're forgetting are that x,y,z,w are all integers and always positive or zero.

this is implicit in the question. the elementary students pick up on it right away. you tried to apply linear algebra to the problem without first checking to see if linear algebra will work in this case.

Share this post


Link to post
Share on other sites
Quote:
Original post by Palidine
you don't solve this with a system of equations, that's why it's "elementary math". there are many possible answers. you can have all pennies, or just pennies and nickles, etc. you solve it by iterative modulus operations. maybe someone can come up with some equations to solve, but this is the easy way.

*** Source Snippet Removed ***


No, there is only one answer because their is a restraint on the problem. The restraint is you have so many coins that add up to a certain amount of money.

Example: You have 3 coins and 25 cents, how many nickels, dimes, pennies, and quaters do you have. Only one possible solution to the problem..

-Dave

Share this post


Link to post
Share on other sites
The problem doesn't even have to have a solution which is a problem =p

ie 27 cents with 4 coins

The solution is unique if there is one though.

Basically you take the set A = {x,y,z,w in N such that 25x + 10y + 5z + 1w = 25}

Then you take the set B = {x,y,z,w in N such that x + y + z + w = 3}

Then your result is A intersection B.

It would be simple to write an algorithm to do exactly that but you could make optimizations to make it run faster.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by ph33r
No, there is only one answer because their is a restraint on the problem. The restraint is you have so many coins that add up to a certain amount of money.

Quote:
Original post by O_o
The solution is unique if there is one though.

No, there can be more than one answer as well as there can be less. For instance, you can get 30c with 6 coins in two ways (25+1+1+1+1+1 or 5+5+5+5+5+5).

Share this post


Link to post
Share on other sites
I'd be able to tell you if it were in pounds, shillings and old pence ;)

Er, a dime's 5c isn't it and I'd guess a quarter's 25c.

Anyway, the solution's a simple box fitting solution in three steps (because you've got three coins).

1) find the largest coin that is less than 25c
2) find the largest coin that is less than the remainder
3) the remainder of that is the value of the last coin

The "less than" contraints aren't "less than or equal" because you know there's three coins.

Share this post


Link to post
Share on other sites
It's so because many "positive integer" problems are not very generalizable, and in many cases can not be solved without doing some iterations. Even simple ones. Intersection of several sets it's general solution to all problems.

With that problem, you can just calculate it as minimal amount of coins, and then do several replacement,like, 10=2*5 or 20=2*10
(for some really weird money systems(something like.... 1,2,3,4,5,6,7,8,9,10,20,25,30,50,100) that might not work in some cases. I don't know your system exactly, probably it's provable that any such problem can be solved by that method).

as about story about PHD students, i'd say, it must mean something is very wrong with education system.

p.s.
Good example of integer problem:
xn+yn=zn
n is integer
n>2
prove that there's no that integers x,y,z so equality is true.
[grin]

Share this post


Link to post
Share on other sites
Quote:
Original post by teamonkey
I'd be able to tell you if it were in pounds, shillings and old pence ;)

Er, a dime's 5c isn't it and I'd guess a quarter's 25c.

Anyway, the solution's a simple box fitting solution in three steps (because you've got three coins).

1) find the largest coin that is less than 25c
2) find the largest coin that is less than the remainder
3) the remainder of that is the value of the last coin

The "less than" contraints aren't "less than or equal" because you know there's three coins.

depends.
what if it's 31 and you need to do that in 7 steps, and there's 25c,5c,and 1c?,

(solution is not unique,25+6*1 or 5*6+1)

largest less than 31: 25
largest less than 6: 5
largest less than 1: none.

So you'll need to traverse a tree.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
As I can't find my password at the moment, and my email's broken, I post this as an AP.

If you're looking for a simple equation to solve it, you won't find one. As you said, there's too many unknowns to solve for. It's a multi-step question.

If anyone's still looking/wanting an answer for this, it's 2 dimes and a nickel.

-overflowed

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!