I'm working on a question that I was hoping J could help answer. I have a overall sum on a report and I'm trying to figure out what line items went into it. The line items can be ignored, added or subtracted.
In other words, given a value let's say 15, what combinations of add, subtracting or ignoring numbers of a list would result in that sum? I found a solution on the right rack in J http://stackoverflow.com/questions/4632322/finding-all-possible-combinations-of-numbers-to-reach-a-given-sum (]#~15=+/@>)(]<@#~[:#:@i.2^#)1 5 10 2.5 2.5 That only appears to work on the add case. For example, if it worked as I desired, it would output (]#~15=+/@>)(]<@#~[:#:@i.2^#) 10 2.5 12 3.5 1 30 10 3.5 2.5 -1 Any ideas on how to approach this or any solutions handy? This post sounds like the right approach but I don't know how to implement it: http://stackoverflow.com/questions/10943562/find-all-the-addition-and-subtraction-combinations-from-an-array-of-numbers My report has between 10-55 possible combinations of numbers on it depending on what the report is run on. The specific one I'm solving right now has 29 Thanks ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
