Timeline for Find all upper, lower and mixed case permutations of a string
Current License: CC BY-SA 3.0
16 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 2, 2017 at 3:24 | comment | added | Daniel McCracken | Sure thing! Glad I was of some help. | |
Sep 2, 2017 at 0:40 | comment | added | SlowLearner | In case you're interested, see initial guesses below. Many thanks for your help :-D | |
Sep 1, 2017 at 23:32 | vote | accept | SlowLearner | ||
Sep 1, 2017 at 7:06 | comment | added | SlowLearner | So after much testing and speculation I decided to add some initial guesses rather than using Brute Force straight away. The initial guesses try to predict common patterns as per 'typical' user name patterns like Mr X: IhaveareallylongfirstnameX would take some time with brute force, but is quick to guess. Will post the revised code as a solution once it is tidied up some more. | |
Sep 1, 2017 at 3:02 | comment | added | SlowLearner |
Well that was interesting your code blew mine completely out of the water on my first few tests with real data (which happen to be names like FirstMiddleLast --> 100001000001000 - then I modified my code slightly and it became even faster, but only because it hits the exit condition sooner due to the way expected patterns are matched. Will need to update the question to explain properly.
|
|
Sep 1, 2017 at 2:29 | comment | added | Daniel McCracken | Huh, interesting. You might be better off using a Dictionary instead of an array to store the results. Then instead of doing separate string comparisons after each permutation, you can do resultsDict.Exists("yourstring") Which is much faster at checking for the existence of a value as the number of values to check increases. My guess is that it'd have better average-case performance than yours, but worse best-case performance. But it'd take some testing to know for sure. | |
Sep 1, 2017 at 2:13 | comment | added | SlowLearner | Oh, transpose bug - I was wondering. Not an Excel user... At any rate I only need one of the permutations so I have been testing the code without outputting anywhere. I have been running each permutation through the encoder and your code is ~4% faster for "abcdefghijklmnopq" and ~8% faster for "abcdefghijklmnopqrst". But since my code can exit sooner (as soon as the first match is found) it will probably be faster (the pragmatic approach) in application. | |
Sep 1, 2017 at 2:01 | comment | added | Daniel McCracken | Nice catch, thanks. I always forget about that Application.Transpose bug, I've run into it a couple of times. Luckily it's an easy fix, just have to turn it into a fake "2d" array. | |
Sep 1, 2017 at 2:00 | history | edited | Daniel McCracken | CC BY-SA 3.0 |
added 91 characters in body
|
Aug 31, 2017 at 23:26 | comment | added | SlowLearner |
I'll update my question to provide some more clarity as to why I am looking to generate the permutations sequentially - basically it is so I can exit the code if I find a match with text in another location. E.g. If EncodePermutation = someString Then Stop . I think this forces the sequential approach as (unstated in the OP) each permutation is encoded and checked against a string.
|
|
Aug 31, 2017 at 23:20 | comment | added | SlowLearner |
I did notice your code generates Error 13 for strings larger than 16 characters: casePermutation "abcdefghijklmnop", activeworkbook.Sheets(1) on this line .Range(.Cells(1, 1), .Cells(UBound(resultsArr), 1)) = Application.Transpose(resultsArr) . I didn't test the impact of non-flippable characters.
|
|
Aug 31, 2017 at 23:20 | comment | added | SlowLearner | Nice. There is 1 big difference in the logic - your code is processing the permutations concurrently whereas mine is processing the permutations sequentially. This is something that I never anticipated and it is really cool to see how other people approach problems differently; and educational too. Now I see the need to be more specific with stating requirements (and I guess seeking clarification). | |
Aug 31, 2017 at 20:58 | history | edited | Daniel McCracken | CC BY-SA 3.0 |
deleted 9 characters in body
|
Aug 31, 2017 at 20:34 | comment | added | SlowLearner | Thanks for that. I'll have a look and get back to you 😎 | |
Aug 31, 2017 at 20:16 | history | edited | Daniel McCracken | CC BY-SA 3.0 |
added 2 characters in body
|
Aug 31, 2017 at 20:11 | history | answered | Daniel McCracken | CC BY-SA 3.0 |