I’m looking to create a function that will return every possible string within a given string length, using a charset.
As an example, a charset of “abc”, and a length of 2 should allow for 9 (3 ^ 2) unique combinations:
aa,
ab,
ac,
ba,
bb,
bc,
ca,
cb,
cc
(List constructed manually)
What method could be used to create such a function?
As always, there are multiple ways to solve what you ask for, this is only one way, using one counter per character in the output string:
aa, ab, ac, ba, bb, bc, ca, cb, cc
One main loop, one loop to build the string and one loop for counting up.
I can imagine this should work with getting modulos per each position of the output string as well.