combinations icon indicating copy to clipboard operation
combinations copied to clipboard

combinations across arrays

Open wanghaisheng opened this issue 9 years ago • 0 comments

lets say i have three arrays var arr1 = ['red', 'orange', 'yellow',]; var arr2 = ['car', 'bus']; var arr3 = ['china']; how to get the following combinations ,order matters, each result should containe 0..1 element of each arr :

red,car,china
red,china,car
car,red,china
car,china,red
china,car,red,
china,red,car

red,bus,china
red,china,bus
bus,red,china
bus,china,red
china,bus,red,
china,red,bus

orange,car,china
orange,china,bus
bus,orange,china
bus,china,orange
china,bus,orange,
china,orange,bus

orange,bus,china
orange,china,bus
bus,orange,china
bus,china,orange
china,bus,orange,

yellow,car,china
yellow,china,car
car,yellow,china
car,china,yellow
china,car,yellow,
china,yellow,car


yellow,bus,china
yellow,china,bus
bus,yellow,china
bus,china,yellow
china,bus,yellow,
china,yellow,bus

red,car
car,red

red,bus
bus,red

orange,car
car,orange,

orange,bus
bus,orange,

yellow,car
car,yellow,

yellow,bus
bus,yellow,

red,china
china,red,

orange,china
china,orange,

yellow,china
china,yellow,

car,china
china,car,

bus,china
china,bus,

wanghaisheng avatar Oct 27 '16 12:10 wanghaisheng