Random string samples & unicode - Reprise

Walter Bright newshound2 at digitalmars.com
Fri Sep 17 23:41:46 PDT 2010


bearophile wrote:
> Think about a "Bulls and cows" game (it's a task of Rosettacode site), it's
> similar to MasterMind, at the beginning you need to generate the secret key,
> four random distinct digits, that later are used in the program, the user has
> to guess them using the number of right items in the right place, or right
> items in the wrong place. To generate the key in Python you may use
> "".join(sample(d, 4)).

Generate a 4 digit random integer and convert it to a string. It's probably a 
lot more efficient than the Python version.


More information about the Digitalmars-d mailing list