Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number Sequence Generation

Status
Not open for further replies.

0ddball

Technical User
Nov 6, 2003
208
GB
Hi hi hi

I'm looking for the best way to create a sequence of numbers based on a binary count. I basicaly want to create the sequence of bit activations so I want to return an array of arrays (2d I guess but hardly important) with the numbers like so:

Code:
{},
{0},
{1},
{0,1},
{2},
{0,2},
{0,1,2},
{3},
{0,3},
{1,3},
{0,1,3},
{2,3},
{0,2,3},
....

These array represent the bits that are on in the binary representation of a number.

I guess I should say that this is *not* coursework, I am not a student - I work as a web developer.

That's why I need help with the compwikaytud stuff :D

I can do this with a whole slew of loops but there has to be a more efficient way. Any idea?

--> Josh


Yet another unchecked rambling brought to you by:
Oddball
 
if this isn't coursework, perhaps you could describe (briefly) the problem that you are trying to solve.


mr s. <;)

 
Hokey dokey

I'm trying to run a simulation of a hand of cards. I want to calculate - using only iterations of the algorith - the likely probabilities of which payouts on which hand of cards. I'm trying to sim multi-play video poker.

The basic idea is that you have a hand of five cards - you can choose to hold or discard any, none or all of the five cards. The ones that you discard are then replaced with a new set of cards.

Code:
1 3 5 6 7
    V
1 X X 6 7
    V
1 2 3 6 7

Like so.

I want to make sure I cover every discard option when I'm running through the iterations of my code.

This is prilimiarily a stress test for a new server I've built, secondarily it's just a bit of fun and threely I want to use one of my rubbish neural nets on my desktop to see if I can beat the iterating server to the punch.

That and it seems like a good solution to this problem would probably teach me a lot.

:) It's a hobby, I don't need a *good* reason!


Yet another unchecked rambling brought to you by:
Oddball
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top