Quantcast
Channel: Active questions tagged string-manipulation - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 186

Convert integer to words of specific length

$
0
0

Assume we give the value from 1 to 26 to alphabets a,b,...,z.

Now given an integer ($n$) i like to generate words of specific length ($l$) that sum of them equals $n$. For instance, if$n=10$, $l=3$;

{aah,abg,acf,ade,aed,afc,agb,aha,bag,bbf,bce,bdd,bec,bfb,bga,caf,cbe,ccd,cdc,ceb,cfa,dae,dbd,dcc,ddb,dea,ead,ebc,ecb,eda,fac,fbb,fca,gab,gba,haa}

with more clear representation:

{aah,abg,acf,ade,aed,afc,agb,aha,bag,bbf,bce,bdd,bec,bfb,bga,caf,cbe,ccd,cdc,ceb,cfa,dae,dbd,dcc,ddb,dea,ead,ebc,ecb,eda,fac,fbb,fca,gab,gba,haa}

How can I write this code in Mathematica. Is teere any predefine function to do this job for me?


Viewing all articles
Browse latest Browse all 186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>