Oops, I got something wrong: "2^15" should be "3^15" and
"2^14" should be "3^14". Sorry for the inconvenience.
Back to the problem. Calling
Control.Monad.replicateM n "012"
with different values of *n* yields:
n=0: [""]
n=1: ["0","1","2"]
n=2: ["00","01","02","10","11","12","20","21","22"]
n=3:
["000","001","002","010","011","012","020","021","022"
,"100","101","102","110","111","112","120","121","122"
,"200","201","202","210","211","212","220","221","222"
]
This clearly shows how each list is built by using the previous
list three times.
As a remedy, you might consider to devise an algorithm that
builds the lists differently, avoiding the multiple use of
complete intermediate lists, e.g. by using each list element
multiple times. The resulting lists would be as shown below:
n=0: [""]
n=1: ["0","1","2"]
n=2: ["00","10","20","01","11","21","02","12","22"]
n=3:
["000","100","200","010","110","210","020","120","220"
,"001","101","201","011","111","211","021","121","221"
,"002","102","202","012","112","212","022","122","222"
]