Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy. This forum is not for asking programming related questions.
I have an array of 63 characters. I want to find out how many unique 6-character combinations can be made with these 63 characters, using each character only once in each combination (character can be used again in next combination - but no character can be used twice in the same combination).
I don't know how to work the equation. I know what a factorial is, but my calculator won't go that large.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Well you have 6 slots, each with a possibility of 63 - N characters, where N is the current slot (0-based). So the formula would look like:
63 x 62 x 61 x 60 x 59 x 58 = 48,920,775,120
well if you continued that out.. that would be N factorial'd.. but that's only part of the equation!
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
The way I learned (made it easier than learning permutations and the like), was to think of it as you have 6 chairs, and 63 people. When you fill the first chair, you only have 62 choices left to fill in the second chair, and 61 for the third, etc. You take each of these total choices and multiply. Don't worry about formulas, make a picture, create your own analogy, whatever makes sense to you, and the logic and numbers will fill themselves in.
Currently that's what i'm doing. And I'm inserting it into a database. Then I'm going to perform a query INSERT INTO `table` (`combo`) VALUES(SELECT DISTINCT `combo` FROM `combos`)
Working... but inefficient, and not guaranteed to get all of the combos.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
meh, nevermind, it's not imperative that I get EVERY unique combination
just a couple million of them
and that will do the job
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Yes, it's ugly with that many nested loops, but it works . You only need to nest a loop for each additional character you want in the final combination (6 characters, 5 nested loops, or 8 characters, 7 nested loops).
That will give you every unique combination of a six character string that can contain letters A-F lowercase. You can obviously modify it to be up to 63 easily, but the logic is there for you