fork(1) download
  1. import itertools as it
  2.  
  3. lang1 = {'a', 'aa'}
  4. lang2 = {'b', 'ab'}
  5.  
  6. lang1lang2 = set([''.join(parts) for parts in it.product(lang1, lang2)])
  7. lang2cubed = set([''.join(parts) for parts in it.product(lang2, repeat = 3)])
  8.  
  9. print("lang1lang2 = {0}".format(lang1lang2))
  10. print("lang2cubed = {0}".format(lang2cubed))
Success #stdin #stdout 0.01s 27704KB
stdin
Standard input is empty
stdout
lang1lang2 = {'aab', 'ab', 'aaab'}
lang2cubed = {'babb', 'ababab', 'babab', 'abbab', 'bbb', 'bbab', 'abbb', 'ababb'}