Jump to content
Sign in to follow this  

How to loop thro all combinations

Recommended Posts



I'm planning to write a small application like "Burn for the Brim" for my own with AutoIt without all the features I don't need.

For all who don't know the program it's filling a medium (CD/DVD) optimally with your files. It circles thru all possibilities and gives the best (or one of them) solution to you.

To work with this problem two arrays are made. Array 1 with the filename and array two with the filesize.

Array 1, Array 2

File1, 200 MB

File2, 300 MB

File3, 500 MB

There are 6 different combinations possible:

1 2 3

1 3 2

2 1 3

2 3 1

3 2 1

3 1 2

For a medium with 700 MB the solution 1 3 is the best, it fills the CD optimally.

My problem is now that I don't have a good idea how to program an algorithm that loops all possible solutions with x files.

Can anybody give me a hint how I can solve this problem?



Share this post

Link to post
Share on other sites

Sounds like a job for a nested For loop.

Also, it would help if you sort your arrays by filesize.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post

Link to post
Share on other sites

Hi Vegeta:

There is also the other poss.:




1 + 2

1 + 3

2 + 3

I think this is a non-trivial algorithm to do elegantly.


If I am too verbose, just say so. You don't need to run on and on.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this