Re: random limited repetition from array...

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




mj.clift@xxxxxxxxxx wrote:
Hi All,

I need to be able to choose a random string from an array. That is easy
enough, but I want to restrict the repetition of that string until one
or two other choices have been made. So the following output would be
ok a,b,c,a,d,c or a,c,d,a,d,a but the following would not; a,b,c,c, or
a,b,b,c, etc... I hope that makes sense.

Almost, but there is some information missing. From what you wrote I
understand that you want to:

Have as input a set of characters
Prepare a string for output, initially empty
Repeatedly choose a random element from this set, and append it to a
string for output
- with the limitation that an element should not be immediately
repeated
At some point - stop, and return the string

The outstanding question is: when do we stop? Taking your example of
abcadc as valid output - would abcad be valid? abca? abc? Tell us the
rule for when to stop and we can proceed.

If it helps to understand what I'm trying to do I have the following
python code.

Python is still on my -to do- list, unfortunately :)

--
Larry Lard
Replies to group please

.



Relevant Pages

  • Re: Added hashes.
    ... >computable as it is for either hash alone. ... If you combine million byte values from digests (Good-hash+ Bad-hash, ... an OTP - random string derived from cosmic radiation. ... If you combine the English phrase with a cosmos-derived random string, ...
    (sci.crypt)
  • RE: Help creating a random string in Perl
    ... Help creating a random string in Perl ... I need to create a random combination of n-1 characters in a source ... Only characters in the source string are in the random string meaning ...
    (perl.beginners)
  • Re: look-ahead search for overlapping
    ... I did not realize that random string of words represented ... > this is a is a test a test for test for fun for fun ... "Reply" at the bottom of the article headers. ...
    (comp.lang.perl.misc)
  • Re: Random String
    ... random string? ... That was rather a good example of why some application programmers, ... If I had been *trying* to implement security software, fine, ...
    (comp.lang.c)
  • Re: Fastest way to search a string for the occurance of a word??
    ... >> characters of the random string to check the RNG is coming up with the ... Well we're at least dealing with the same string then:) ... 4.52s for regular expressions, for a million iterations (one test ...
    (microsoft.public.dotnet.languages.csharp)