[AS1.0/2.0] Need help with 'simple' algorithm!

Hello there,

This is my first post on this forum but I’ve learned a lot from it already, soon maybe I will be able to contribute.

Anyway, I wasn’t sure where to post this but I need to solve what I thought should be a simple problem that I can’t get my head around at the moment (been working all day).

I have 3 arrays, each containing a random number of elements.

Lets say: array1(), array2(), array3()

I want to display information from 6 array elements on my stage, ideally 2 elements from each array. However, as the arrays may contain more or less than 2 elements, if an array has < 2, I’d like to make up for it if the other arrays have > 2 by showing extra from those arrays instead. As evenly as possible. I’d like to know at the end how many elements of each array to add to the stage (Maximum of 6 altogether).

i.e.

If we say array1.length() is 3, array2.length() is 1, and array3.length() is 1 - then I’d like it to display 3 from array1, and 1 from the other two arrays.

If we say array1.length() is 0, array2.length() is 4, and array3.length() is 5 - then I’d like it to display 3 from each of array2, and array3.

So as to get 6 wherever possible, and spread them out evenly wherever possible.

Sorry if I’ve explained it badly.

Hope someone can help! :crying:

Spiderflash