Thread: Combinations and permutations

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    5

    Combinations and permutations

    I have code that will produce every combination of chars for a given char set so say char set a-z for 8 string length would give every combination like aaaaaaaa-zzzzzzzz.

    This is produces a big file.

    However I see you can also produce permutations which seem to be unique outputs of a given char set. This code seems to do that,

    Find all permutations of a string in C++ (Using Backtracking and STL) - Techie Delight

    How would I modify this code so it produces an 8 char output instead of 3?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Maybe
    string str = "ABCDEFGH";

    The algorithm doesn't care how long your string is.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    5
    I get that but for a char set a-z. I doubt it's possible the way it's set out.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Well the code you found has nothing to do with the problem you have.

    I suppose that's the issue.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Nov 2006
    Posts
    5
    I want an a 8 char string set of a-z however doing every combo such as aaaaaaaa-zzzzzzzz is too large a file so I'm looking for others ways to produce this data. Do you have any ideas?

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    What else are you going to do with it after you've generated it?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Figure out what you want; then, post it in this thread!

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  8. #8
    Registered User
    Join Date
    Nov 2006
    Posts
    5
    It's a password list to crack various hashes with hashcat. Using full brute aaaaaaa-zzzzzzzz takes too long and is too big a file, many gb's, so I'm looking for a compromise, still combinations of a-z but with no adjacent chars the same so I'm looking into permutations.

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    If you were looking to nefariously crack hashed passwords, then your approach probably isn't very good, but I'm not going to discuss better methods here because password cracking discussion is out of the scope of this forum, as a rule.

    For permutations, there is std::next_permutation from <algorithm>
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 03-25-2015, 02:42 PM
  2. k-permutations
    By miguel.pinr in forum C Programming
    Replies: 3
    Last Post: 11-27-2012, 05:23 AM
  3. permutations
    By computation in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 02:46 PM
  4. Permutations
    By mekaj in forum C++ Programming
    Replies: 5
    Last Post: 01-23-2006, 09:10 AM
  5. permutations
    By packer in forum C Programming
    Replies: 13
    Last Post: 06-02-2005, 12:54 AM

Tags for this Thread