The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Generating sequence of 0s and 1s with no repetition
Replies: 3   Last Post: Jul 22, 2013 2:47 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 1
Registered: 7/22/13
Generating sequence of 0s and 1s with no repetition
Posted: Jul 22, 2013 1:32 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I need to generate a sequence of 100 numbers composed of 0s and 1s only.
But I must guarantee that no more that 3 repetitions occur.
For xample:
1 2 2 1 2 2 1 1 1 2 1... its ok
1 2 1 2 2 2 2 1 it's not.
I used randi for the generation of the sequence. But i'm a bit stuuck with the remaining part. I'm sure there is an efficient way of achieving this.
Thanks for any help.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.