-
Dec 5th, 2021, 09:43 AM
#1
[RESOLVED] Possible patters of a 4 digit number
I've tried combination and permutation calculators but perhaps because I don't know how to express what I want, I haven't gotten the answer I need. For example with a three digit number there are these patterns:
111
112
211
123
222 is not in that list because it has the same pattern as 111 and 332 is not in the list because it has the same pattern as 112, etc.
What would that look like for a four digit number?
-
Dec 5th, 2021, 11:11 AM
#2
Re: Possible patters of a 4 digit number
Why is 211 on the list, wouldn't that be the same pattern as 100?
Or are zeroes not allowed in the permutations.
Also is that the full list for three digit numbers? If so, why aren't numbers like 321 included?
-
Dec 5th, 2021, 11:16 AM
#3
Re: Possible patters of a 4 digit number
For three digit numbers maybe I should have said that the four patterns are
All digits are the same
The left 2 digits are the same but the 3rd digit is different
The right 2 digits are the same but the 1st digit is different
All the digits are different
And zeros are allowed.
-
Dec 5th, 2021, 11:20 AM
#4
Re: Possible patters of a 4 digit number
Okay, then I don't understand why 211 is there and not 100? The right 2 digits are the same, but the left digit is different in both.
-
Dec 5th, 2021, 11:24 AM
#5
Re: Possible patters of a 4 digit number
Also, is the rule only that the digits are different, not how much they are different by? For example, if 100 is on the list, should 400 be on the list, or should it be omitted?
100 is 0,-1,-1 relative difference, whereas 400 is 0,-4,-4 relative difference. But they're both XYY if the relative difference doesn't matter.
-
Dec 5th, 2021, 11:35 AM
#6
Re: Possible patters of a 4 digit number
Sorry, my fault; I'm looking for a pattern of three numbers and I'm using 1, 2 and 3 to represent those numbers. So yes, 100 is the same pattern as 211, but so is 622, 955, 033, etcetera and I'm only interested in the pattern. My purpose is to use VBA to recognize if a four digit number has a certain pattern and do different things with the number depending on its pattern. I'm looking for help to list all the petterns using 1, 2, 3 and 4.
-
Dec 5th, 2021, 11:36 AM
#7
Re: Possible patters of a 4 digit number
Put another way, if we follow the rules you described as I've understood them, why isn't the list for 3 digit number matches as follows:
100 <- ABB
101 <- ABA
102 <- ABC
110 <- AAB
111 <- AAA
-
Dec 5th, 2021, 11:38 AM
#8
Re: Possible patters of a 4 digit number
Originally Posted by jpbro
Put another way, if we follow the rules you described as I've understood them, why isn't the list for 3 digit number matches as follows:
100 <- ABB
101 <- ABA
102 <- ABC
110 <- AAB
111 <- AAA
In those terms the patterns for a 3 digit number are:
AAA
AAB
BAA
ABC
-
Dec 5th, 2021, 11:42 AM
#9
Re: Possible patters of a 4 digit number
Why no BBA? And I still don't understand why 211 would appear instead of 100.
-
Dec 5th, 2021, 11:43 AM
#10
Re: Possible patters of a 4 digit number
For 4 digit numbers I have the feeling that there are 24 (4 * 3 * 2) patterns starting with
AAAA
AAAB
BAAA
-
Dec 5th, 2021, 11:46 AM
#11
Re: Possible patters of a 4 digit number
Yes you are correct, BBA should be in the list and so should ABB! That would make 6 (3 * 2) patterns.
-
Dec 5th, 2021, 11:49 AM
#12
Re: Possible patters of a 4 digit number
Based on what I understood from before, BBA is the same as AAB (because the 2 left digits are the same but different from the right-most digit in both), so only one should be included. Are you sure it should now be considered different?
-
Dec 5th, 2021, 11:59 AM
#13
Re: Possible patters of a 4 digit number
And if it's truly just checking for different ABCD patterns where ABCD and DCBA would be considered the same pattern since they are both "all different", then I think the 4 digit list would be as follows:
1000 <-- BAAA
1001 <-- BAAB
1002 <-- BAAC
1010 <-- BABA
1011 <-- BABB
1012 <-- BABC
1020 <-- BACA
1021 <-- BACB
1022 <-- BACC
1023 <-- BACD
1100 <-- BBAA
1101 <-- BBAB
1102 <-- BBAC
1110 <-- BBBA
1111 <-- BBBB
-
Dec 5th, 2021, 12:18 PM
#14
Re: Possible patters of a 4 digit number
-
Dec 5th, 2021, 12:23 PM
#15
Re: [RESOLVED] Possible patters of a 4 digit number
This is the VB6 code I used to generate the list (requires RC6.dll reference) in case it's of any use:
Code:
Sub GenNums()
Dim lo_Dict As cSortedDictionary
Dim lo_Collection As cCollection
Dim lo_Num As cArrayList
Dim lo_Nums As cArrayList
Dim l_Num As String
Dim l_FirstNum As Long
Dim l_PatternChar As Long
Dim l_Key As String
Dim ii As Long
Dim jj As Long
Set lo_Dict = New_c.SortedDictionary
Set lo_Collection = New_c.Collection
Set lo_Num = New_c.ArrayList(vbString) '
Set lo_Nums = New_c.ArrayList(vbLong)
For ii = 1000 To 9999
l_Num = CStr(ii)
l_FirstNum = Left$(l_Num, 1)
l_PatternChar = 65
If Not lo_Collection.Exists(CStr(l_FirstNum)) Then lo_Collection.Add CStr(l_PatternChar), CStr(l_FirstNum)
lo_Num.Add CStr(l_PatternChar)
For jj = 2 To Len(l_Num)
l_Key = CStr(Mid$(l_Num, jj, 1))
If lo_Collection.Exists(l_Key) Then
lo_Num.Add lo_Collection(l_Key)
Else
l_PatternChar = l_PatternChar + 1
lo_Num.Add CStr(l_PatternChar)
lo_Collection.Add CStr(l_PatternChar), l_Key
End If
Next jj
l_Key = lo_Num.Join
If Not lo_Dict.Exists(l_Key) Then
lo_Dict.Add l_Key, ii
lo_Nums.Add ii
End If
lo_Collection.RemoveAll
lo_Num.RemoveAll
Next ii
lo_Nums.Sort
For ii = 0 To lo_Nums.Count - 1
Debug.Print lo_Nums(ii), "<-- " & Replace$(Replace$(Replace$(Replace$(lo_Nums(ii), "0", "A"), "1", "B"), "2", "C"), "3", "D")
Next ii
End Sub
Maybe there is a better way to solve the problem, but it did the trick.
-
Dec 5th, 2021, 12:32 PM
#16
Re: [RESOLVED] Possible patters of a 4 digit number
Originally Posted by MartinLiss
I've tried combination and permutation calculators but perhaps because I don't know how to express what I want, I haven't gotten the answer I need. For example with a three digit number there are these patterns:
111
112
211
123
222 is not in that list because it has the same pattern as 111 and 332 is not in the list because it has the same pattern as 112, etc.
What would that look like for a four digit number?
Does 3 even need to appear in your pattern list?
It seems like your pattern list should be a matter of the number of places, not the number of digits, so you aren't making a pattern out of three digits, 1,2,3 but of a length of three digit places.
So, your base patterns should be.
111
112
122 same as 211 in your list
121 same as 123 in your list
For 4 places, I get
1111
1112
1122
1121
1222
1221
1211
1212
I did these by hand, but if you can confirm my patterns for 3 and 4 places match what you are looking for, then I think the pattern can be easily generated.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Dec 5th, 2021, 12:36 PM
#17
Re: [RESOLVED] Possible patters of a 4 digit number
Does that dll exist under Windows XP.? That's where my old VB6 is but it doesn't show up in my References.
-
Dec 5th, 2021, 01:04 PM
#18
Re: [RESOLVED] Possible patters of a 4 digit number
No, it's a free third-party DLL that isn't included with XP. The version 6 that I used also doesn't work with XP, but version 5 does. If you're interested you can get it at vbrichclient.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|