Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mathematics knundrum
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00780672
Message ID:
00780829
Views:
32
Bruce,

As I told, it is not my program, and it has some limitations. I believe all in deep questions should go to the author. You can download the code and correct it if you feel it should be done.


>>Ok, I need to refresh my memory on this routines. Let us start with the pereb.prg (author Rustam Mukumov, most likely at rustam@sibron.ru).
>>
>>There is an array paNumbers(tnArray) containing the list of numbers. In the original code this array is created in the code and populated with integers; length of the array is the first program parameter.
>>
>>You need to pass your array to the program instead.
>>
>>The second parameter is the target total, and the third parameter indicates whether you need to list all of the solutions or you want to know only how many solutions are there.
>>
>>For example, you can run the original program like
>>
>>=pereb(10,40,.t.)
>>
>>to meet target total 40 for numbers from 1 to 10 in the list. You should see the list of 20 solutions.
>
>No offense Yuri, as this is a somewhat tricky math problem, but 20 is not the right answer. You must chack ALL possible sums within the first 10 numbers: all the pair sums, all the triplet sums, all the quadruplet sums...all the way up to the sum of all 10 numbers at once.
>
>The count of these sums is much larger: C(10,1) + C(10,2) + C(10,3) + ... + C(10,10),
>
>Which is a total of 10 + 45 + 120 + 210 + 252 + 210 + 120 + 45 + 10 + 1 = 1,033 different possible sums that musy all be checked, unless a "hit" is found and the loop can end sooner.
>
>(If my math is correct, usually I let a program do the factorial & summing work :-)
>
>Do these programs do this type of combination-checking?
Previous
Reply
Map
View

Click here to load this message in the networking platform