I want to generate a random list of six characters that only contain characters from "0...9" and "A...Z".
For this I can define
ToCharacterCode[{"ABCDEFGHIJKLMONPQRSTUVWXYZ", "0123456789"}]
I can modify the answer here as
rndnew = FromCharacterCode@
RandomChoice[Join @@ Range[{48, 65}, {57, 90}], #] &
I can now generate five of these strings by doing
rndnew[{5, 6}]
This results in something like
{"35UVUS", "F7WIJG", "PQSBHF", "PIHTSW", "R3MDM6"}
My question is how can I guarantee that these strings have no collisions (I know this is a very large space)? Is there a better way to code this using random over the range of the size of this set (like a linear congruential generator with that range) to make sure the strings are unique or is there a facility in Mathematica to do that?
RandomChoice
withRandomSample
? $\endgroup$See Also
section of that function's documentation. $\endgroup$