Peegee
02-09-2012, 09:35 PM
Or excel works too, but you would have to hand hold me with excel.
Pretend for argument's sake I'm an idiot who only can program in C
good luck!
In today's episode, PG receives a call from a client. The client was debited $5,278.53 (eg) out of their bank account and does not know what payments break down this total.
The good thing is that I or the client can pull up a list of transactions that went out on that day.
eg:
2859.34
128.33
483.44
592.22
1820.00
500.00
719.19
1400.00
300.00
(so the transactions that add up to the figure needed are: 2859.34, 300, 1400, 719.19)
How would I go about programming this? This is how I would start -
1) go down the list and grab the line as a variable
2) is the variable > the figure sought y ? if yes skip
3) now i have variable x which is < y
4) go down the list. is x2 > y-x1 ? if yes skip
5) if no, is x2 = y-x1? if yes finish return x1 and x2 (how?)
6) if no, store x1 and x2 somewhere. x1 = x1+x2
continue
but this only checks whether 2 numbers add up to y. Since there could be potentially infinite numbers, I am open to using an array that does not have a set amount of variables (but something like 50 would be fine lol I am not going to read out that many numbers to a client when i could be charging them 100s of dollars in service fees by saying 'nope.avi' )
Does this make sense? I feel like people who haven't quit programming for 13 years (sorry) are having an aneurysm reading this.
edit: lol yes there can be more than one solution. is this question too complicated to solve?
I found this online - read this for more discussion - http://www.mrexcel.com/pc09.shtml
Pretend for argument's sake I'm an idiot who only can program in C
good luck!
In today's episode, PG receives a call from a client. The client was debited $5,278.53 (eg) out of their bank account and does not know what payments break down this total.
The good thing is that I or the client can pull up a list of transactions that went out on that day.
eg:
2859.34
128.33
483.44
592.22
1820.00
500.00
719.19
1400.00
300.00
(so the transactions that add up to the figure needed are: 2859.34, 300, 1400, 719.19)
How would I go about programming this? This is how I would start -
1) go down the list and grab the line as a variable
2) is the variable > the figure sought y ? if yes skip
3) now i have variable x which is < y
4) go down the list. is x2 > y-x1 ? if yes skip
5) if no, is x2 = y-x1? if yes finish return x1 and x2 (how?)
6) if no, store x1 and x2 somewhere. x1 = x1+x2
continue
but this only checks whether 2 numbers add up to y. Since there could be potentially infinite numbers, I am open to using an array that does not have a set amount of variables (but something like 50 would be fine lol I am not going to read out that many numbers to a client when i could be charging them 100s of dollars in service fees by saying 'nope.avi' )
Does this make sense? I feel like people who haven't quit programming for 13 years (sorry) are having an aneurysm reading this.
edit: lol yes there can be more than one solution. is this question too complicated to solve?
I found this online - read this for more discussion - http://www.mrexcel.com/pc09.shtml