01-20-2004, 11:04 PM | #1 | ||
College Starter
Join Date: Oct 2000
Location: Calgary
|
OT: Elementary Math Problem
The concept is simple. Payment is made that exceeds the bill. Determine the least amount of coins and bills required to make change.
Solving the problem isn't what I'm after as a recursive solution works. What I'm wondering is if there is a general formula that works regardless of the amount paid or the cost of the bill? Could it be done without introducing a new variable for each type of coin and bill? |
||
01-20-2004, 11:17 PM | #2 |
Grizzled Veteran
Join Date: Oct 2000
Location: Syracuse, NY
|
umm my head
As a cashier for 2 years in HS, I got to be pretty good at making change... |
01-20-2004, 11:22 PM | #3 |
Pro Starter
Join Date: Apr 2003
Location: Alabama
|
Sounds like an optimmization problem to me. not sure how simple a general fomula would have to be.
|
01-21-2004, 12:36 AM | #4 |
Coordinator
Join Date: Jan 2001
Location: Keene, NH
|
there's a flaw in my math somewhere - but the below excel formula works for many amounts
anyways, replace 'a1' with your amount and this will calculate the number of coins you need in most cases. not sure why some numbers don't work right... C=INT(A1/0.25)+INT((A1-((INT(A1/0.25))*0.25))/0.1)+(INT((A1-((INT(A1/0.25))*0.25)-((INT((A1-((INT(A1/0.25))*0.25))/0.1))*0.1))/0.05))+(INT((A1-((INT(A1/0.25))*0.25)-((INT((A1-((INT(A1/0.25))*0.25))/0.1))*0.1)-((INT((A1-((INT(A1/0.25))*0.25)-((INT((A1-((INT(A1/0.25))*0.25))/0.1))*0.1))/0.05))*0.05))/0.01))
__________________
Mile High Hockey |
01-21-2004, 01:21 AM | #5 | |
Pro Starter
Join Date: Dec 2003
Location: In the thick of it.
|
Quote:
If any of you out there have been wondering if Draft Dodger is an Alien from outer space, I think you have your answer right there.
__________________
I'm still here. Don't touch my fucking bacon. |
|
01-21-2004, 01:45 AM | #6 | |
Hall Of Famer
Join Date: Apr 2002
Location: Back in Houston!
|
Quote:
Looks a lot like the stuff I was messing with last night (lots of nested IFs). Then again, this just required a case statement in Excel to look prettier. =IF($O2=17,D2*1.76,IF($O2=18,D2*1.53,IF($O2=19,D2*1.33,IF($O2=20,D2*1.21,IF($O2=21,D2*1.11,IF($O2=22,D2*1.1,IF($O2=23,D2*1.05,D2))))))) SI
__________________
Houston Hippopotami, III.3: 20th Anniversary Thread - All former HT players are encouraged to check it out! Janos: "Only America could produce an imbecile of your caliber!" Freakazoid: "That's because we make lots of things better than other people!" |
|
01-21-2004, 01:47 AM | #7 |
College Starter
Join Date: Oct 2000
Location: Calgary
|
Cool. Thanks, guys!
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|