Pelican Parts
Parts Catalog Accessories Catalog How To Articles Tech Forums
Call Pelican Parts at 888-280-7799
Shopping Cart Cart | Project List | Order Status | Help



Go Back   Pelican Parts Forums > Miscellaneous and Off Topic Forums > Off Topic Discussions


Reply
 
LinkBack Thread Tools Rating: Thread Rating: 2 votes, 3.00 average.
Author
Thread Post New Thread    Reply
Student of the obvious
 
LeeH's Avatar
 
Join Date: May 2000
Location: Phoenix
Posts: 7,714
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?

__________________
Lee
Old 11-29-2010, 08:20 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #1 (permalink)
AutoBahned
 
RWebb's Avatar
 
Join Date: Jul 2007
Location: Greater Metropolitan Nimrod, Orygun
Posts: 55,993
Garage
I'm not in your target group, but it sounds like an al Gebra problem to me...
Old 11-29-2010, 08:21 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #2 (permalink)
jyl jyl is online now
Registered
 
jyl's Avatar
 
Join Date: Jan 2002
Location: Nor California & Pac NW
Posts: 24,550
Garage
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.
Old 11-29-2010, 08:37 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #3 (permalink)
Information Junky
 
island911's Avatar
 
Join Date: Mar 2001
Location: an island, upper left coast, USA
Posts: 73,189
Quote:
Originally Posted by RWebb View Post
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.
__________________
Everyone you meet knows something you don't. - - - and a whole bunch of crap that is wrong.
Disclaimer: the above was 2¢ worth.
More information is available as my professional opinion, which is provided for an exorbitant fee.
Old 11-29-2010, 11:08 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #4 (permalink)
Dog-faced pony soldier
 
Porsche-O-Phile's Avatar
 
Join Date: Feb 2004
Location: A Rock Surrounded by a Whole lot of Water
Posts: 34,187
Garage
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.
__________________
A car, a 911, a motorbike and a few surfboards

Black Cars Matter
Old 11-29-2010, 11:33 PM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #5 (permalink)
Feelin' Solexy
 
Tishabet's Avatar
 
Join Date: Oct 2003
Location: WA
Posts: 3,788
So you are trying to find every possible permutation of any combo of these numbers which adds up to the magic number?
Old 11-30-2010, 05:12 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #6 (permalink)
Registered Usurper
 
DARISC's Avatar
 
Join Date: Sep 2005
Posts: 13,824
Quote:
Originally Posted by island911 View Post
but he wants an Al Gore rhythm here.
That's a Stu Pedasso comment.
__________________
'82 SC RoW coupe
Old 11-30-2010, 05:48 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #7 (permalink)
Registered
 
id10t's Avatar
 
Join Date: Mar 2003
Posts: 10,324
Got the numbers and the known total to work for?
__________________
“IN MY EXPERIENCE, SUSAN, WITHIN THEIR HEADS TOO MANY HUMANS SPEND A LOT OF TIME IN THE MIDDLE OF WARS THAT HAPPENED CENTURIES AGO.”
Old 11-30-2010, 05:53 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #8 (permalink)
Registered Usurper
 
DARISC's Avatar
 
Join Date: Sep 2005
Posts: 13,824
Quote:
Originally Posted by id10t View Post
Got the numbers and the known total to work for?
Since the numbers vary, x and y?
__________________
'82 SC RoW coupe
Old 11-30-2010, 05:58 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #9 (permalink)
Cars & Coffee Killer
 
legion's Avatar
 
Join Date: Sep 2004
Location: State of Failure
Posts: 32,246
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.
__________________
Some Porsches long ago...then a wankle...
5 liters of VVT fury now
-Chris

"There is freedom in risk, just as there is oppression in security."
Old 11-30-2010, 06:01 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #10 (permalink)
Moderator
 
Z-man's Avatar
 
Join Date: Feb 2001
Location: NJ, USA
Posts: 9,628
Garage
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.
__________________
2010 Cayman S - 12-2020 -
2014 MINI Cooper S Coupe - 05-17 - 05-21
1989 944S2 - 06-01 - 01-14
Carpe Viam.
<><
Old 11-30-2010, 06:04 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #11 (permalink)
Student of the obvious
 
LeeH's Avatar
 
Join Date: May 2000
Location: Phoenix
Posts: 7,714
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.
__________________
Lee
Old 11-30-2010, 06:16 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #12 (permalink)
 
Registered Usurper
 
DARISC's Avatar
 
Join Date: Sep 2005
Posts: 13,824
"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.
__________________
'82 SC RoW coupe
Old 11-30-2010, 06:22 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #13 (permalink)
Registered
 
Join Date: May 2002
Location: St Louis
Posts: 4,211
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.
__________________
Rick
88 Cab
Old 11-30-2010, 06:34 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #14 (permalink)
Student of the obvious
 
LeeH's Avatar
 
Join Date: May 2000
Location: Phoenix
Posts: 7,714
Quote:
Originally Posted by DARISC View Post
"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 View Post
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!
__________________
Lee
Old 11-30-2010, 07:11 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #15 (permalink)
Registered
 
Join Date: Mar 2008
Location: Chicagoland
Posts: 2,695
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
Old 11-30-2010, 07:15 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #16 (permalink)
Registered
 
Join Date: May 2002
Location: St Louis
Posts: 4,211
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.
__________________
Rick
88 Cab
Old 11-30-2010, 07:20 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #17 (permalink)
Moderator
 
Z-man's Avatar
 
Join Date: Feb 2001
Location: NJ, USA
Posts: 9,628
Garage
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.
__________________
2010 Cayman S - 12-2020 -
2014 MINI Cooper S Coupe - 05-17 - 05-21
1989 944S2 - 06-01 - 01-14
Carpe Viam.
<><
Old 11-30-2010, 07:50 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #18 (permalink)
canna change law physics
 
red-beard's Avatar
 
Join Date: Jul 2000
Location: Houston, Tejas
Posts: 43,366
Garage
I think that we've spent more time discussing this than it would have taken manually to figure this out...
__________________
James
The pessimist complains about the wind; the optimist expects it to change; the engineer adjusts the sails.- William Arthur Ward (1921-1994)
Red-beard for President, 2020
Old 11-30-2010, 07:55 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #19 (permalink)
Moderator
 
Z-man's Avatar
 
Join Date: Feb 2001
Location: NJ, USA
Posts: 9,628
Garage
Quote:
Originally Posted by LeeH View Post
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!

__________________
2010 Cayman S - 12-2020 -
2014 MINI Cooper S Coupe - 05-17 - 05-21
1989 944S2 - 06-01 - 01-14
Carpe Viam.
<><
Old 11-30-2010, 08:33 AM
  Pelican Parts Catalog | Tech Articles | Promos & Specials    Reply With Quote #20 (permalink)
Reply


 


All times are GMT -8. The time now is 07:16 AM.


 
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, 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 -    DMCA Registered Agent Contact Page
 

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