Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Fastest and efficient way to determine combination of items

$
0
0
Hello again, guys and gals..

I'm having problem that I need smarter people to help me.
Basically, I want to find the fastest and efficient way for the script to process the data.

Let's say I have 8 items in a clothing store's computer.
A=Hats
B=Shirts
C=Pants
D=Skirts
E=Jeans
F=Shorts
G=Jacket
H=Shoes

And here's the .ini:
[Day01]
Order=Mr. X
Brands=Lion,,Dog,Cat,Cow,,,Aligator

It means that Mr. X orders:
Hats with brand Lion, no Shirts, Pants with brand Dog, Skirts with brand Cat, Jeans with brand Cow, no Shorts, no Jacket, and Shoes with brand Aligator.

The question is what is the fastest or efficient way for the script to process this information?
I could simply put it in an array using StringSplit and let it check whether the array is empty or not, but it means it would need 8 loops each time to process. I want to cut the process so the loop is minimized.


I was thinking to make it in a binary combination.
http://www.mathsisfun.com/binary-combinations.html
When the data is saved, the script will check what items are ordered and what not (loop for checking in here is okay), then it will make a code. So, the script will know what to process, without doing any unnecessary loop.
Ex: let's say I have only 2 items, so the combination will be 4.
A B   Code
0 0 1
0 1 2
1 0 3
1 1 4
If I got order for item A only, the code is 3. If only item B, the code is 2. If both A and B, the code is 4. Thus the script set an additional key in the .ini for the code. And the script could process efficiently by looking that code. But with 8 items, it would be 256 combinations. And should the items be added, it would be too much.

Is there any other way to do this efficiently or better?
Any help would be appreciated.
Thank you.

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>