Question: Listing strings of length n composed of k given elements

Hi I have a problem. As you know the number of strings of length n, composed of k given elements is k^n. I want to list all this k^n strings. For example if the length is 3 (n=3) and elements are choosing from {0,1} we obtain: 000 001 010 011 100 101 110 111 Actually, for n=3 the solution is simple: B:=[0,1]: for i from 1 to nops(B) do for j from 1 to nops(B) do for k from 1 to nops(B) do print(B[i],B[j],B[k]); od: od: od; I need a code working for all n any idea? Emrah AKYAR Anadolu University Faculty of Science Department of Mathematics 26470 Eskisehir / TURKEY
Please Wait...