+ Reply to Thread
Results 1 to 6 of 6

Calculate possible combinations where the total sum equals 30

  1. #1
    Registered User
    Join Date
    05-20-2010
    Location
    cheshire
    MS-Off Ver
    Excel 2002
    Posts
    8

    Calculate possible combinations where the total sum equals 30

    Hi People,

    I have math problem i want to solve, and i think a vba code could help!

    If i have the numbers 8,6,4 and 2

    i want to know how many possible combinations using any amount of the numbers,where the total equals 30.

    e.g 8,6,4,2,2,2,2,2,2 or 8,6,4,4,2,2,2,2

    hope this makes sense! thought its worth asking.

  2. #2
    Registered User
    Join Date
    05-20-2010
    Location
    cheshire
    MS-Off Ver
    Excel 2002
    Posts
    8

    Re: Calculate possible combinations where the total sum equals 30

    Update here is my potential idea on how to solve this..... feel free to shoot holes in the idea

    find out what the lowest number is that can be made (regardless of the order of numbers e.g 224688 then find the highest number 222222468

    then step up each number from 224688 e.g 224688,224689,224690

    then using boolean statements i.e does the number contain a 9 if yes then get rid... if not it... does it contain an 8 e.t.c

    it would also have to count to make sure at least ONE 2,4,6,8 is contained in the number too as long as the criteria is met is puts these into a column.

    next problem is : 224688 technically is the same combination as 886422 if we're ignoring order of numbers.... so would then have to eliminate the duplicates somehow.....

    this was my only way of thinking how to solve this issue.... potentially
    Last edited by Buksh; 05-01-2013 at 10:17 AM.

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Calculate possible combinations where the total sum equals 30

    I think I would start with the case where fifteen 2's make 30. From this permutation, I can substitute one 4 for every two 2's (if that makes sense to you). From the same fifteen 2's I can substitute one 6 for every three 2's, and then substitute one 8 for every four 2's. So the iterations look like:
    15 2's
    13 2's 1 4's
    11 2's 2 4's
    ...
    12 2's 1 6's
    9 2's 2 6's
    ...
    11 2's 1 8's
    7 2's 2 8's
    ...
    and on and on
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Registered User
    Join Date
    05-20-2010
    Location
    cheshire
    MS-Off Ver
    Excel 2002
    Posts
    8

    Re: Calculate possible combinations where the total sum equals 30

    Hi Mr Shorty,

    Thanks for your reply. i have sadly seen this as a challenge now and even though there is no benefit to knowing this i kinda of want to work it out.

    your suggestion was my first idea then i realised that the numbers 2,4,6 and 8 have to be used at least once...

    this changed the numbers slightly. so i came up with the lowest number being 224688 unless ive completely overlooked something? then i assumed the highest number would be the reverse however again i have probably completely overlooked something.

    EDIT : i am almost certain i have overlooked something but this might be self doubt lol!

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Calculate possible combinations where the total sum equals 30

    then i realised that the numbers 2,4,6 and 8 have to be used at least once...
    I obviously wasn't aware of that requirement, though I'm not sure how different the basic algorithm would be.

    Start with the same fifteen 2's
    Take out four for the required 8
    Take out three for the required 6
    Take out two for the required 4
    Take out one for the required 2

    Now you have one of each value totaling 20
    There are five 2's left over totaling 10.
    Now you are back to the same problem you started with, only what combinations add up to 10 instead of 30.

  6. #6
    Registered User
    Join Date
    05-20-2010
    Location
    cheshire
    MS-Off Ver
    Excel 2002
    Posts
    8

    Re: Calculate possible combinations where the total sum equals 30

    Ahh ok i see where you are coming from with that!

    now i look at it that way there doesnt seem like there would actually be that many combinations?

    i was thinking this would best be done via VBA as the no. of combinations would be a lot...only im not so sure now.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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