Jump to content
  • Advertisement
Sign in to follow this  
Kommi10

ok what is the equation for this?

This topic is 4850 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

lets say I am generating a list of combinations. Now lets say I have 1 item that appears 3 times, and 5 spaces. The list would look like the following: 1 = item x = space 111xx 11x1x 11xx1 1x11x 1x1x1 1xx11 x111x x11x1 x1x11 xx111 There are 10 total possible combinations. I was wondering if there is a mathimatical equation that can tell me which number in the list is (for example) 1xx11? I know it is the 6'th one in the list because I generated the list. But is there away to derive that it is the 6'th one without generating the list?

Share this post


Link to post
Share on other sites
Advertisement
No, because your list isn't unique. Your list can be reordered and still fit the given requirement (1 item 3 times and 5 spaces).

Share this post


Link to post
Share on other sites
If the 1 was a 1 and the x was a 0 each would have a unique binary number.

16 4 1
8 2
111xx = 28
11x1x = 26
11xx1 = 24
1x11x = 22
1x1x1 = 21
1xx11 = 19
x111x = 14
x11x1 = 13
x1x11 = 11
xx111 = 7

You could probably do something with this.

If you can describe the way that you want to use the system u describe, then i might be able to help further.

ace

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
In general, for one item that appears N times in M spaces, the solution can be found by looking at the Nth entry in the Mth iteration of Pascal's triangle...

specifically, the 5th line here is:

1 5 10 10 5 1

(but note carefully that the 'third' entry is actually the second 10, as the line is 0-based indexing... in other words, there is 1 way to arrange the items such that your value appears 0 times, and 1 way to arrange where it appears 5 times).

So google for a solution to Pascal's triangle, and you'll have your answer.

--ajas

Share this post


Link to post
Share on other sites
It's pretty simple. Just use a binary representation like ace said and put the resulting numbers into an array as a look-up table.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!