Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
I have a question about and algorithm I am creating.
I've got the necesary answer from my equation. But in that loop I need to find out from what combinations that value is given.
"Combinations" means, if you are watching the algorithm, that every variable is taking a valuea between 1 and 4 and entering the eqution.
I think that there are 4 cases in wich that result is given.
How do I find out those 4 cases? (in the same algorithm or even in an other is good; i need and output something like an array)
As in the attached?
There are only two solutions. You can test this by replacing the "if min..." in your algorithm by "if s=-6"
You only need to post in one category - repeat posts are unnecessary.
Alan
Fred has shown you how to get the first of your solutions (you may get the last bychanging the < to <=).
Alan gave you a routine which returns all solutions. But be careful, depending on the target function used you may get additional "solutions" not corresponding with the absolute minimum. This always will happen if the first combination of the four values does not yield the absolute minimum. You can cope with that by inserting the following line in Alan's code (reset vectors if a new min is found).
Find attached a third variant which, as I guess, would also solve your problem.
BTW, sometimes the display name affects if one is taken more or less seriously.
--> May the force be "Avec Toi", Sir.