Listing strings of length n composed of k given elements

October 06 2006 by Emrah Akyar 36
false
Maple

0


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
 
Loading Comments & Answers

You must be logged into your MaplePrimes account in order to post a comment. If you don't have an account, you can create an account here.

     

Forgot Your Password? Create an Account