codegreen

06-06-2007, 10:35 PM

Hi,

Lets say I have an array:

$fruitarr = array("apple", "banana", "orange", "lemon", "lime", "strawberry");

And I need to generate a list of smoothies over a period of 8 weeks. Each week only two of the fruits can be used together at a time. So for example, the choices for week 1 would be:

apple, banana

orange, lemon

lime, strawberry

week 2 would be:

banana, orange

lemon, lime

strawberry, apple

and so on....not repeating together until each has been paired up at least once. (Since there are 8 weeks, the combos for later weeks will resemble the combos of first few weeks)

How do I generate these combo lists?

Also lets say I have an odd number of fruits in my array:

$fruitarr = array("apple", "banana", "orange", "lemon", "lime");

week 1 would be:

apple, banana

orange, lemon

lime, apple <- first gets repeated

week 2:

banana, orange,

lemon, lime,

apple, banana <- first gets repeated

How could I generate these combos? (for odd numbers of fruits)

Thanks. I hope this smoothie example makes my problem easier to conceptualize.

If anyone could help I would greatly appreciate it.

Lets say I have an array:

$fruitarr = array("apple", "banana", "orange", "lemon", "lime", "strawberry");

And I need to generate a list of smoothies over a period of 8 weeks. Each week only two of the fruits can be used together at a time. So for example, the choices for week 1 would be:

apple, banana

orange, lemon

lime, strawberry

week 2 would be:

banana, orange

lemon, lime

strawberry, apple

and so on....not repeating together until each has been paired up at least once. (Since there are 8 weeks, the combos for later weeks will resemble the combos of first few weeks)

How do I generate these combo lists?

Also lets say I have an odd number of fruits in my array:

$fruitarr = array("apple", "banana", "orange", "lemon", "lime");

week 1 would be:

apple, banana

orange, lemon

lime, apple <- first gets repeated

week 2:

banana, orange,

lemon, lime,

apple, banana <- first gets repeated

How could I generate these combos? (for odd numbers of fruits)

Thanks. I hope this smoothie example makes my problem easier to conceptualize.

If anyone could help I would greatly appreciate it.