+ Reply to Thread
Results 1 to 15 of 15

5 digit number combinations

Hybrid View

  1. #1
    Registered User
    Join Date
    09-02-2010
    Location
    Southampton
    MS-Off Ver
    Excel 2007
    Posts
    7

    Exclamation 5 digit number combinations

    I need all the 5 digit number combination using the character 0-9, but there cannot not be any duplicate numbers.

    For example, 01198, 02297, these couldn't be used as they have duplicate numbers.

    Once the numbers with duplicate numerals have been removed, I need to come up with a formula that will remove every additional number that contains the same 5 numerals. For example, if I already have 01234, I need to remove (or somehow identify) every other combination of those four numbers....12340, 24301, 30124, etc

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,336

    Re: 5 digit number combinations

    Read this first
    http://www.mathsisfun.com/combinator...mutations.html

    Combinations or Permutations?

  3. #3
    Registered User
    Join Date
    09-02-2010
    Location
    Southampton
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: 5 digit number combinations

    It is a combination

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,336

    Re: 5 digit number combinations

    Did you read down the page for Combinations without repititions?
    Do you want us to list all the numbers for you in cells in Excel?
    How many numbers will there be?

  5. #5
    Registered User
    Join Date
    09-02-2010
    Location
    Southampton
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: 5 digit number combinations

    If you read my post properly you can tell i asked for it without repititions, yes or just a code so i can do it myself easily.

    I have no idea how many numbers its whi im asking.

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,336

    Re: 5 digit number combinations

    Hi Puppiie,
    I'm not trying to be dumb, but your original post was confusing for me. I'm confused between your use of of the words number and digit.

    In your second sentence in your post you said that:
    For example, 01198, 02297, these couldn't be used as they have duplicate numbers.

    I couldn't tell if the problem(s) with these was that 0 and 9 (digits) had been used in both numbers or if it was because you didn't allow the 1 digit to be used in a single number.

    I've taught combinations and permutations in the past and it is always confusing if there are replacements or not and how to structure the problem correctly.

    This is why I'm asking.
    Last edited by MarvinP; 09-02-2010 at 11:08 AM.

  7. #7
    Registered User
    Join Date
    09-02-2010
    Location
    Southampton
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: 5 digit number combinations

    Oh sorry about the confusion

    i didn't mean the mubers 0 and 9 i ment because in each of the 5 digits there 2 ones and in the other 2 twos.

    Sorry for the confusion hope this helps

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,336

    Re: 5 digit number combinations

    Would the sum of the digits being unique solve your problem?
    0+1+2+3+4 = 10 , ...., 5+6+7+8+9 = 35

  9. #9
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: 5 digit number combinations

    Not sure how that would work, Marvin.. as 01567 summed is the same as 20467. (And many other matching sums)

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,336

    Re: 5 digit number combinations

    Hi Paul,
    The teacher in me is coming out. You are absolutely correct and I knew that.

    Now - are there C(10,5) = 252 possible numbers?

    Let Puppiie struggle a little bit with that question before we provide an answer.

    I'm exploring pulling the digits out of the 5 digit number, sorting them and putting back as a number.

    Would this accomplish the task? Example: 43210 -> 01234 as would 34012 -> 01234 after sorting digits.
    Then each 5 digit number would have a value and could eliminate dupicates in the question asked.

    I've used the sum of the digits before as an easy first test to see if I need to go further in the test.

  11. #11
    Registered User
    Join Date
    09-02-2010
    Location
    Southampton
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: 5 digit number combinations

    I'm not going to lie you have got me a bit confused.

    but you are right i could not have 43210 aswell as 01234 because the order of the numbers do not matter.

  12. #12
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,336

    Re: 5 digit number combinations

    Puppiie -

    You confusion is GREAT! As we try to give answers, it's important for us to understand your question. You have to decide if 01234 is the same as 43210. It was not obvious, to me, from your original post.

    I decided you wanted to say that 12345 was the same as 54321. I've written a User Defined Function that sorts (from small to large) 5 digits and returns the value. Example 54321 = 12345 , 13245 = 12345 ect.

    If you use this function in a column next to your text digits it will be easier to tell which are the same, as the value will be the same.

    'This function takes a 5 character long string
    'Made up of digits from 0-9 (no repeating digits)
    'Returns the minimim value of the 5 digits as a test for uniqueness
    
    Function MinValue5String(NumStr As String) As Double
    
    Dim Ctr As Integer
    Dim Ctr2 As Integer
    Dim Vals(5) As Integer
    Dim SortVals(5) As Integer
    Dim MinVal As Double
    
    'Test to see if exactly 5 character long string
    If Len(NumStr) <> 5 Then
        MsgBox ("Need 5 characters in the number string")
        GoTo Not5Long
    End If
    
    For Ctr = 1 To 5
        Vals(Ctr) = Mid(NumStr, Ctr, 1)
    Next Ctr
    
    'Sort the numbers small to large
    For Ctr2 = 1 To 4
        For Ctr = 1 To 4
            If Vals(Ctr) > Vals(Ctr + 1) Then
                Vals(0) = Vals(Ctr)
                Vals(Ctr) = Vals(Ctr + 1)
                Vals(Ctr + 1) = Vals(0)
            End If
        Next Ctr
    Next Ctr2
    
    'Test to see if any digits repeat
    For Ctr = 1 To 4
        If Vals(Ctr) = Vals(Ctr + 1) Then
            MsgBox ("Two digits are the same - not allowed")
            GoTo Not5Long
        End If
    Next Ctr
    
    'Build value of digits
    MinValue5String = 0
    For Ctr = 1 To 5
        MinValue5String = MinValue5String + Vals(Ctr) * 10 ^ (5 - Ctr)
    Next Ctr
    
    Not5Long:
    
    End Function

    To use the above User Defined Function (UDF)

    If A1 contains "43267" (any 5 character string of digits)
    In B1 type "=MinValue5String(A1)"
    B1 will then show the value 23467.

    I'm not sure this answers your entire question but may be a start for determining if any 2 Five Digit strings have the same exact 5 digits in them as another (based on their minimum 5 digit values).

  13. #13
    Registered User
    Join Date
    09-02-2010
    Location
    Southampton
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: 5 digit number combinations

    I am sorry but i am a complete fool, is it possible to get a list f numbers i am really struggling with this =/

  14. #14
    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: 5 digit number combinations

            --a-- --b-- --c-- --d-- --e-- --f--
        1   43210 53210 63210 73210 83210 93210
        2         54210 64210 74210 84210 94210
        3         54310 64310 74310 84310 94310
        4         54320 64320 74320 84320 94320
        5         54321 64321 74321 84321 94321
        6               65210 75210 85210 95210
        7               65310 75310 85310 95310
        8               65320 75320 85320 95320
        9               65321 75321 85321 95321
       10               65410 75410 85410 95410
       11               65420 75420 85420 95420
       12               65421 75421 85421 95421
       13               65430 75430 85430 95430
       14               65431 75431 85431 95431
       15               65432 75432 85432 95432
       16                     76210 86210 96210
       17                     76310 86310 96310
       18                     76320 86320 96320
       19                     76321 86321 96321
       20                     76410 86410 96410
       21                     76420 86420 96420
       22                     76421 86421 96421
       23                     76430 86430 96430
       24                     76431 86431 96431
       25                     76432 86432 96432
       26                     76510 86510 96510
       27                     76520 86520 96520
       28                     76521 86521 96521
       29                     76530 86530 96530
       30                     76531 86531 96531
       31                     76532 86532 96532
       32                     76540 86540 96540
       33                     76541 86541 96541
       34                     76542 86542 96542
       35                     76543 86543 96543
       36                           87210 97210
       37                           87310 97310
       38                           87320 97320
       39                           87321 97321
       40                           87410 97410
       41                           87420 97420
       42                           87421 97421
       43                           87430 97430
       44                           87431 97431
       45                           87432 97432
       46                           87510 97510
       47                           87520 97520
       48                           87521 97521
       49                           87530 97530
       50                           87531 97531
       51                           87532 97532
       52                           87540 97540
       53                           87541 97541
       54                           87542 97542
       55                           87543 97543
       56                           87610 97610
       57                           87620 97620
       58                           87621 97621
       59                           87630 97630
       60                           87631 97631
       61                           87632 97632
       62                           87640 97640
       63                           87641 97641
       64                           87642 97642
       65                           87643 97643
       66                           87650 97650
       67                           87651 97651
       68                           87652 97652
       69                           87653 97653
       70                           87654 97654
       71                                 98210
       72                                 98310
       73                                 98320
       74                                 98321
       75                                 98410
       76                                 98420
       77                                 98421
       78                                 98430
       79                                 98431
       80                                 98432
       81                                 98510
       82                                 98520
       83                                 98521
       84                                 98530
       85                                 98531
       86                                 98532
       87                                 98540
       88                                 98541
       89                                 98542
       90                                 98543
       91                                 98610
       92                                 98620
       93                                 98621
       94                                 98630
       95                                 98631
       96                                 98632
       97                                 98640
       98                                 98641
       99                                 98642
      100                                 98643
      101                                 98650
      102                                 98651
      103                                 98652
      104                                 98653
      105                                 98654
      106                                 98710
      107                                 98720
      108                                 98721
      109                                 98730
      110                                 98731
      111                                 98732
      112                                 98740
      113                                 98741
      114                                 98742
      115                                 98743
      116                                 98750
      117                                 98751
      118                                 98752
      119                                 98753
      120                                 98754
      121                                 98760
      122                                 98761
      123                                 98762
      124                                 98763
      125                                 98764
      126                                 98765
    Entia non sunt multiplicanda sine necessitate

  15. #15
    Registered User
    Join Date
    09-02-2010
    Location
    Southampton
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: 5 digit number combinations

    Thanks SHG you helped me crack my lockbox!!!

+ 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