Pelican Parts Forums

Pelican Parts Forums (http://forums.pelicanparts.com/)
-   Off Topic Discussions (http://forums.pelicanparts.com/off-topic-discussions/)
-   -   Question for the math/computer programmer/Excel geniuses (http://forums.pelicanparts.com/off-topic-discussions/577840-question-math-computer-programmer-excel-geniuses.html)

LeeH 11-29-2010 09:20 PM

Question for the math/computer programmer/Excel geniuses
 
Simple enough problem. I have a list of 25 numbers. Some, but not all of those numbers, when added up equal a known total. How do I figure out which of the numbers from the list equal my total.

Figured there would be a Java calculator for this, but in searching I don't find any on the web. I saw some advanced Excel/programming discussion, but wasn't able to understand how to translate 100 lines of code to Excel. Anyone know how to pull this off?

RWebb 11-29-2010 09:21 PM

I'm not in your target group, but it sounds like an al Gebra problem to me...

jyl 11-29-2010 09:37 PM

I think that will be hard to do with plain Excel, without writing VBA code. I'd start by sorting the numbers in descending order and then solving manually, do it a couple times for different sets of 25 numbers, see if your process can be captured in spreadsheet functions.

island911 11-30-2010 12:08 AM

Quote:

Originally Posted by RWebb (Post 5700255)
I'm not in your target group, but it sounds like an al Gebra problem to me...

but he wants an Al Gore rhythm here.

Porsche-O-Phile 11-30-2010 12:33 AM

Well since you brought Al Gore into it:

I'd add up all the numbers, verify the result a couple of times to be absolutely sure it's correct, then report whatever you want anyway (even though it conflicts with the result) and then point to the original data set as "proof". Pretty simple.

Tishabet 11-30-2010 06:12 AM

So you are trying to find every possible permutation of any combo of these numbers which adds up to the magic number?

DARISC 11-30-2010 06:48 AM

Quote:

Originally Posted by island911 (Post 5700378)
but he wants an Al Gore rhythm here.

That's a Stu Pedasso comment.

id10t 11-30-2010 06:53 AM

Got the numbers and the known total to work for?

DARISC 11-30-2010 06:58 AM

Quote:

Originally Posted by id10t (Post 5700590)
Got the numbers and the known total to work for?

Since the numbers vary, x and y?

legion 11-30-2010 07:01 AM

Yep, the tricky thing here is there could be multiple solutions. Solving this programatically would generally yield the first solution encountered.

I would probably create an array for each number and assign a number to that array for each iteration through the set. I would also store a sum for each iteration. This would allow me to keep track of what I've already added (to avoid duplication) and to see if there are multiple solutions.

The next trick is writing an algorithm that could successfully add each permutation of the numbers in the set. I'd have it start buy just "summing" each individual number, then every unique pair of numbers, then every unique set of three numbers, and so on up to the size of the set.

Z-man 11-30-2010 07:04 AM

If you have access to a mainframe, I can whip up a recursive REXX exec that would spit out the combos in a jiffy...

When you say "adding together" do you mean only two numbers can be added together at a time, or can you have more? (ex: x+y only, or x+y, x+y+z, w+x+y+z...etc. ) If it is only two numbers at a time, you can probably write a macro for that using IF statements and < and > tests.

-Z-man.

LeeH 11-30-2010 07:16 AM

Ok... here's the "word problem" version:

One of my clients put some business charges on her personal credit card. There were 25 charges in total (personal + business) on the credit card statement for the month. When the bill arrived, she paid a portion of the bill out of her personal checking account (unknown amount), and paid the business charges from the business checking account. So, I have the 25 charges on the credit card statement, and I have the amount paid from the business account.

She has the original statement somewhere, but moved a couple of months ago and it will take time to track down. I'm still surprised there wasn't a Java calculator posted for this.

DARISC 11-30-2010 07:22 AM

"when added up equal a known total"

Exactly?
Equal to or greater than?
If so, then by no more than a certain #/%?
Seems it would be the exception rather than the rule that any pair of numbers would equal a known total, no?
Wish I was good at math. :(

rick-l 11-30-2010 07:34 AM

So the number of possible sums is combin(25,1) + combin(25,2) + combin(25,3) + ... combin(25,25)?

That is only 33.5 million possible sums. you can do that in your head easy.

LeeH 11-30-2010 08:11 AM

Quote:

Originally Posted by DARISC (Post 5700638)
"when added up equal a known total"

Exactly?
Equal to or greater than?
If so, then by no more than a certain #/%?
Seems it would be the exception rather than the rule that any pair of numbers would equal a known total, no?
Wish I was good at math. :(

Yes... the exact total is the amount she paid from her business checking

Quote:

Originally Posted by rick-l (Post 5700663)
So the number of possible sums is combin(25,1) + combin(25,2) + combin(25,3) + ... combin(25,25)?

That is only 33.5 million possible sums. you can do that in your head easy.

Yes, but since we know the target sum, it seems like there is a minimum number of the set required to add up to at least that sum. So, if you add up the set from largest to smallest you can figure out that it will take at least that many members of the set to equal the total. Oh well... I know what i mean! :D

krystar 11-30-2010 08:15 AM

yea it's basically improbable that u'll find the matches. unless the set of 25numbers just happen to only coincidentally have one combination that match up to the total.

tell the client to get her receipts

rick-l 11-30-2010 08:20 AM

This is the silly question that computers were made for. Google combination algorithms and wrtie a visual basic program to test all 33.55 millon of them.

Z-man 11-30-2010 08:50 AM

The client can request the CC company to send a copy of that statement. It may be easier to then determine what was personal and what was business expense.

-Z-man.

red-beard 11-30-2010 08:55 AM

I think that we've spent more time discussing this than it would have taken manually to figure this out...

Z-man 11-30-2010 09:33 AM

Quote:

Originally Posted by LeeH (Post 5700629)
Ok... here's the "word problem" version:

One of my clients put some business charges on her personal credit card. There were 25 charges in total (personal + business) on the credit card statement for the month. When the bill arrived, she paid a portion of the bill out of her personal checking account (unknown amount), and paid the business charges from the business checking account. So, I have the 25 charges on the credit card statement, and I have the amount paid from the business account.

She has the original statement somewhere, but moved a couple of months ago and it will take time to track down. I'm still surprised there wasn't a Java calculator posted for this.

Hmm - I've thought about it a little more, and have a question which may help clear up your dilema:

Do you know if one of her expenses was for a train ride? If so, was she travelling from Albuquerque, New Mexico to San Jose, California, at an average speed of 103 km/hr, while another tran was travelling from San Jose to Alburquerque at an average speed of 96km/hr? If she left Albuquerque at 3:06pm, and the train leaving from San Jose departed the trian depot at 1:23pm on the same day, at what time will the two trains meet? Bonus question: at what distance from San Jose will the trains meet?

Now, if one of her expenses was for an airline, then I have another question: was the plane on a conveyor belt when it took off?

One more question: did any of the transactions have anything to do with a Black Audi Wagon by any chance?

Yes, this will be on the final exam...

-Z-man.

Apologies for derailing (sic) this thread!

RWebb 11-30-2010 12:44 PM

Quote:

Originally Posted by island911 (Post 5700378)
but he wants an Al Gore rhythm here.

for the poorly educated among you (like Islet) my al Gebra post was pun on the fact that we inherited algebra from the Arabs

they developed it during the peak of their civilization, ~~ 1,000 AD

Paco Anton 11-30-2010 12:48 PM

Post the 25 numbers and the amount paid and we'll figure it out.

RWebb 11-30-2010 12:51 PM

I agree with doing some manual "prototypes" of this in Excel.

There is indeed a min. set that will satisfy your criteria & I don't think it will be in the millions. real issue is how many min. sets are there?

why not sort the 25 entries from largest to smallest; then copy the smallest 24 to a new worksheet; then copy 23... etc.

work back from there & rule out the small #'s - that should give at least one result

if not, keep track of it, and add back the biggest #, drop the 2nd biggest;

Lather/Rinse/Repeat

it's a weird Q. for me right now b/c I'm reading a book on Richard Feynmann and how when he was at Los Alamos, they set up "circles of girls on calculating machines" and ran things thru those circles until they got answers - and a bomb

Paco Anton 11-30-2010 12:58 PM

I'd do a randomized approach.

1. Assign a random 0/1 value to each of the 25 Numbers
2. Add up the numbers with "1" value
3. If they add up to the goal value the you are set
4. If not cycle again

Leave the Excel woking all night and wake up to get the solution.

Post the numbers. I want to test my approach ;)

Aurel 11-30-2010 05:30 PM

I am assuming this is for business deductions on a tax return...Here is the quick and dirty way I would do it:

1. Sort the receipts in column A
2. Add the receipts is column B
3. If yer lucky, one of the sums will be the exact number
4. If not lucky, select the receipts that get closest to the total
5. Call it a day, let the IRS figure the details out :D.

Good thing I am not a CPA :rolleyes:.

LeeH 11-30-2010 07:28 PM

Amount paid from business checking = $1617.87
Charges:
486.87
32.48
247.84
9.64
27.19
30.00
79.36
28.17
119.53
26.79
530
141.65
11.4
40.83
53.15
36.93
11.40
84.25
44.39
58.25
328.53
175.82
182.44
332.67
3.87
-250.00 ... a $250 CREDIT from a return!

MBAtarga 11-30-2010 07:59 PM

so far through trial and error I'm as close as 0.02

Aurel 11-30-2010 08:00 PM

Here is your result:

486.87
32.48
247.84
9.64
27.19
30
79.36
28.17
119.53
26.79
530

That was easy my friend SmileWavy

MBAtarga 11-30-2010 08:08 PM

I concur. At least that's a possible solution.

Aurel 11-30-2010 08:14 PM

Quote:

Originally Posted by MBAtarga (Post 5702213)
I concur. At least that's a possible solution.

There might be other solutions, but since those were all grouped together on the top of the list, this has to be it.

Red88Carrera 11-30-2010 08:30 PM

Here's a link to an Excel template that does what you want. You will need the "Solver" add-in installed and enabled for it to work. I checked it out and it worked for me.
Excel Template - What Numbers In A Set Total A Target Value

Red88Carrera 11-30-2010 09:13 PM

Use the template I linked to and just let it run. It will run for about a minute.

486.87
27.19
79.36
28.17
530
11.4
40.83
11.4
44.39
175.82
182.44

There seems to be some funny accounting going on here. If you add up the first 11 items, they equal the exact amount paid on the business account. But if you look at my results, they also add up to the exact same amount. Do you want me to calculate the probability of that happening? Highly unlikely.

LeeH 11-30-2010 09:47 PM

I think Aurel has it! She paid the balance toward the end of the month, but before the end of the statement period, so several of the later charges actually happened after my client made her payment.

I sent her a note asking which charges were tied to this payment. I'd expect she'll be able to confirm this eventually.

Hodgey 12-01-2010 08:18 PM

....use the Excel add-in programme called 'solver'....

easy peasy, lemon squeezy.......


All times are GMT -8. The time now is 01:44 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0
Copyright 2025 Pelican Parts, LLC - Posts may be archived for display on the Pelican Parts Website


DTO Garage Plus vBulletin Plugins by Drive Thru Online, Inc.