I’d like to create a function which will generate a 3 char key string after each loop.
There are 26 chars in the alphabet and I’d like to generate totally unique 3 char keys (A-Z).
The output would be 17,576 unique 3 char keys (A-Z) – not case sensitive.
Can anyone give me an idea on how to create a more elegant function without randomly generating keys and checking for duplicate keys?
Is it possible
Thank you.
If I read your question correctly you want to have a function that returns a key of the form “ABC” where each of the letters is selected randomly but the same combination of letters is never issued twice.
Do you mean never issued twice per execution of the code or never issued twice “ever”?
Either way I would look at generating all possible combinations, shuffling them and then storing them either in a member array or a file/database depending on your needs. You will also need to store an index which you simply increment each time you issue a key.