Menu

#10 Permutations with repetitions

v1.0_(example)
closed
bofh28
1
2014-04-27
2014-03-12
Tyrion
No

Hi!
I have tried a bit, but I was not able to find a way to generate permutations with repetitions.That is, if I run

$ crunch 4 4 -p 0011

it displays also duplicates: it generates all the 4! = 24 permutations of 4 characters. In this case instead the permutations are 4C2 = 6.

I'm looking forward to hearing from you.
Best regards

Related

Support Requests: #10

Discussion

  • bofh28

    bofh28 - 2014-03-20

    I am not sure what you are looking for. Do you want duplicates or not?

    ./crunch 4 4 10
    Crunch will now generate the following amount of data: 80 bytes
    0 MB
    0 GB
    0 TB
    0 PB
    Crunch will now generate the following number of lines: 16
    1111
    1110
    1101
    1100
    1011
    1010
    1001
    1000
    0111
    0110
    0101
    0100
    0011
    0010
    0001
    0000

    ./crunch 4 4 -o test -p 1100

    Crunch will now generate approximately the following amount of data: 120
    bytes
    0 MB
    0 GB
    0 TB
    0 PB
    Crunch will now generate the following number of lines: 24

    crunch: 100% completed generating output

    sort test | uniq

    0011
    0101
    0110
    1001
    1010
    1100

    If you want something else please let me know.

    Thanks,

    On Wed, Mar 12, 2014 at 2:16 PM, Tyrion myrddin89@users.sf.net wrote:


    Status: open
    Group: v1.0_(example)
    Labels: permutation repetition
    Created: Wed Mar 12, 2014 07:16 PM UTC by Tyrion
    Last Updated: Wed Mar 12, 2014 07:16 PM UTC
    Owner: bofh28

    Hi!
    I have tried a bit, but I was not able to find a way to generate
    permutations with repetitions.That is, if I run

    $ crunch 4 4 -p 0011

    it displays also duplicates: it generates all the 4! = 24 permutations of
    4 characters. In this case instead the permutations are 4C2 = 6.

    I'm looking forward to hearing from you.
    Best regards


    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/crunch-wordlist/support-requests/10/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

     

    Related

    Support Requests: #10

  • Tyrion

    Tyrion - 2014-03-20

    Thank you very much for your support.
    What I was looking for is your second example, where are allowed duplicated characters and the generated strings are permutations of the first.
    I was not aware of the uniq utility.
    But I wondered why crunch can not generate on its own unique permutations.

     
    • bofh28

      bofh28 - 2014-03-22

      The permute function is basic. It doesn't support the min max parameters.
      When you have duplicate characters as the input string, 0011 in your case,
      crunch treats them as unique characters that you want permuted. I haven't
      found an algorithm to replace permute yet.

      Thanks,

      On Thu, Mar 20, 2014 at 3:47 AM, Tyrion myrddin89@users.sf.net wrote:

      Thank you very much for your support.
      What I was looking for is your second example, where are allowed
      duplicated characters and the generated strings are permutations of the
      first.
      I was not aware of the uniq utility.
      But I wondered why crunch can not generate on its own unique permutations.


      Status: open
      Group: v1.0_(example)
      Labels: permutation repetition
      Created: Wed Mar 12, 2014 07:16 PM UTC by Tyrion
      Last Updated: Wed Mar 12, 2014 07:16 PM UTC
      Owner: bofh28

      Hi!
      I have tried a bit, but I was not able to find a way to generate
      permutations with repetitions.That is, if I run

      $ crunch 4 4 -p 0011

      it displays also duplicates: it generates all the 4! = 24 permutations of
      4 characters. In this case instead the permutations are 4C2 = 6.

      I'm looking forward to hearing from you.
      Best regards


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/crunch-wordlist/support-requests/10/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Support Requests: #10

  • Tyrion

    Tyrion - 2014-03-22

    In this case I would suggest std::next_permutation, which does exactly that. I have tried the code myself and it is very straightforward:

    std::string str = "000111";

    do
    {
    std::cout << str << std::endl;
    }
    while (std::next_permutation(str.begin(), str.end()));

    This function increments the initial string with the smallest possible amount using lexicographical ordering.
    Clearly the loop ends when the permuted string is the biggest lexicographically.
    Obviously one can also consider a std::vector<std::string> if there is more than one string to permute and apply the same function.</std::string>

    Best regards

     
  • bofh28

    bofh28 - 2014-04-27
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB