math - Finding cartesian product in Java -


i want find cartesian product of set of elements. here's example

example 1 : sets :(ab) (bc) (ca) 

cartesian product is,

abc aba acc aca bbc bba bcc bca

example 2 : sets : (zyx) b c 

cartesian product is,

zbc ybc xbc

so thinking of algorithm execute in java can find cartesian product of particular amount of groups defined @ compile time @ start.

you can use sets.cartesianproduct() method google's guava libraries generate cartesian products:

com.google.common.collect.sets.cartesianproduct(set[] yoursets) 

if easy!


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -