Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combinations across arrays #4

Open
wanghaisheng opened this issue Oct 27, 2016 · 0 comments
Open

combinations across arrays #4

wanghaisheng opened this issue Oct 27, 2016 · 0 comments

Comments

@wanghaisheng
Copy link

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,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant