+ Reply to Thread
Results 1 to 9 of 9

Possible combination of numbers

  1. #1
    Registered User
    Join Date
    06-03-2015
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    34

    Unhappy Possible combination of numbers

    Hi,

    I want to generate all possible combination of 7 numbers (non-repetitive) out of 189 (1 to 189) and all seven number total must be 161.

    Any help?

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Possible combination of numbers

    Hi.

    Do you realise that the number of different combinations of 7 numbers from 189 is more than one-and-a-half trillion, i.e.:

    1,527,510,868,092

    which would require 1,456,748 columns to be fully populated in a standard Excel 2010 sheet, which would need 89 worksheets with every single cell fully populated?

    Good luck!!

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Possible combination of numbers

    Quote Originally Posted by XOR LX View Post
    Hi.

    Do you realise that the number of different combinations of 7 numbers from 189 is more than one-and-a-half trillion, i.e.:

    1,527,510,868,092

    which would require 1,456,748 columns to be fully populated in a standard Excel 2010 sheet, which would need 89 worksheets with every single cell fully populated?

    Good luck!!

    Regards
    That was what concerned me at first glance. However there is a condition that the sum of the 7 numbers in each combination must equal 161.
    I'm guessing that this should seriously reduce the number of integers that needs to be considered, For instance we can immediately rule out anything above 140.

    Then I'm also surmising that we may be able to use the information that the average of any 7 must be 23. Still thinking of some sort of algorithm.
    Last edited by Richard Buttrey; 06-14-2015 at 06:59 AM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Possible combination of numbers

    Quote Originally Posted by Richard Buttrey View Post
    For instance we can immediately rule out 1-17 and anything above 140.
    Can we? I think you mean more that we can rule out cases where all 6 numbers are less than 29 (I think you mean this number, not 17?).

    Because e.g. the number 1 cannot be ruled out per se.

    But how this helps I'm not quite sure, since it may in any case require that all combinations of those values are first enumerated before then applying a conditional statement on that list to the effect of eliminating those which don't meet these criteria.

    Regards

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Possible combination of numbers

    Yes, quite correct. I had in fact edited my post.

    It's also the case that any 7 consecutive numbers below 25 can be excluded. However I grant you that somehow disallowable combinations have in some way to be excluded before processing the rest of the combinations and that's certainly not clear to me.

    shg's usually good at this sort of stuff. Maybe he'll have some ideas.

  6. #6
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,414

    Re: Possible combination of numbers

    Hi arunsjain,

    This looks like one of your previous post. As mentionned by the other, there are probably too many possibilities

    Here's a slightly modified version of the code I provided you the first time.
    You can change the value of n to do more iterations but this may take more time and/or crash Excel.

    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Possible combination of numbers

    Quote Originally Posted by Richard Buttrey View Post
    shg's usually good at this sort of stuff. Maybe he'll have some ideas.
    I've been working on the very topic lately, but it tends to make my brain explode.

    I've got functions to count and generate all of the partitions of a number. For example, the partitions of 8 are

    8
    7+1
    6+2
    6+1+1
    5+3 5+2+1
    5+1+1+1 4+4
    4+3+1 4+2+2 4+2+1+1
    4+1+1+1+1
    3+3+2 3+3+1+1
    3+2+2+1 3+2+1+1+1
    3+1+1+1+1+1
    2+2+2+2 2+2+2+1+1
    2+2+1+1+1+1
    2+1+1+1+1+1+1
    1+1+1+1+1+1+1+1

    For 161, there are 118,159,068,427.

    I also have a function to calculate the number of partitions that include only distinct numbers (aka strict partitions). For the number 13, for example, there are 18:

    13

    12 + 1
    11 + 2
    10 + 3
    9 + 4
    8 + 5
    7 + 6

    10 + 2 + 1
    9 + 3 + 1
    8 + 4 + 1
    7 + 5 + 1
    8 + 3 + 2
    7 + 4 + 2
    6 + 5 + 2
    6 + 4 + 3

    7 + 3 + 2 + 1
    6 + 4 + 2 + 1
    5 + 4 + 3 + 1

    For 161, there are 15,065,878,135 strict partitions.

    What I don't have is a function to calculate the number of strict partitions of a given length (e.g., a function that returns 3 for (13, 4), and some unknown number for (161, 7)). I know what the generating function is, but can't get my brain around how to evaluate it.

    Whatever the number is, though, listing them would take way more than a full column, and that interests me not at all.
    Last edited by shg; 06-14-2015 at 05:58 PM.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Possible combination of numbers

    Have some light amusement with this code if you like.
    It took my computer 34 secs to produce a million of the results that you seem to want.
    I don't particularly want to work out the total number of results needed, but you can overflow more (than the million) results into additional columns of your worksheet if you feel like it, and wait until you either run out of patience or your computer runs out of memory. I'd also note that the code isn't particularly efficient.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-03-2015
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    34

    Re: Possible combination of numbers

    Thank you all for your time and reply. Highly appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. A combination of 3 numbers that appear most
    By bines in forum Excel General
    Replies: 5
    Last Post: 12-09-2014, 12:44 PM
  2. [SOLVED] How to show all the possible combination of a set of numbers?
    By joey_qf@163.com in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-12-2013, 02:15 PM
  3. combination of these numbers would sum
    By alisapooh in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-22-2009, 12:27 PM
  4. combination of numbers
    By dc in forum Excel General
    Replies: 0
    Last Post: 06-08-2006, 02:55 PM
  5. combination of numbers
    By ErnestoMarti in forum Excel General
    Replies: 36
    Last Post: 10-23-2005, 05:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1