Permutation lists?? Really Need Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roger B.

    Permutation lists?? Really Need Help

    Hello,

    I am working on a personal interest project and have been racking my brain
    on this problem for about 5 hours total now, and tracking through old
    newsgroup posts but haven't figuried it out yet so heres my question.

    I want to be able to make a list of all possible combinations (repitiions
    are allowed) of numbers where X is a arbitrary initeger between something
    like 0 and 100
    and the number of x's is arbitrary as well in this example 10 x's are
    present.

    x,x,x,x,x,x,x,x ,x,x

    I want to find all possible combinations for this. In the end I would have
    a list of all possible combinations of the x's in groups of ten whre each x
    would be a number between 0 and 100.

    Thanks for any help.


  • Buster Copley

    #2
    Re: Permutation lists?? Really Need Help

    Roger B. wrote:
    [color=blue]
    > I am working on a personal interest project and have been racking my brain
    > on this problem for about 5 hours total now [...][/color]

    I'm not sure I believe that.
    [color=blue]
    > I want to be able to make a list of all possible combinations (repitiions
    > are allowed) of numbers where X is a arbitrary initeger between something
    > like 0 and 100
    > and the number of x's is arbitrary as well in this example 10 x's are
    > present.
    >
    > x,x,x,x,x,x,x,x ,x,x
    >
    > I want to find all possible combinations for this. In the end I would have
    > a list of all possible combinations of the x's in groups of ten whre each x
    > would be a number between 0 and 100.[/color]

    You do know there are 100 000 000 000 000 000 000, right? Think
    of a systematic way of writing them. You might start like this:

    0,0,0,0,0,0,0,0 ,0
    0,0,0,0,0,0,0,0 ,1
    0,0,0,0,0,0,0,0 ,2
    0,0,0,0,0,0,0,0 ,3
    0,0,0,0,0,0,0,0 ,4

    The Arabs had this all worked out many centuries ago, and
    I'm pretty sure they didn't need C++ to do it.

    Good luck,
    Buster.

    Comment

    • Thore B. Karlsen

      #3
      Re: Permutation lists?? Really Need Help

      On Thu, 25 Sep 2003 01:44:04 GMT, "Roger B." <rogerab22@hotm ail.com>
      wrote:
      [color=blue]
      >Hello,
      >
      > I am working on a personal interest project and have been racking my brain
      >on this problem for about 5 hours total now, and tracking through old
      >newsgroup posts but haven't figuried it out yet so heres my question.
      >
      >I want to be able to make a list of all possible combinations (repitiions
      >are allowed) of numbers where X is a arbitrary initeger between something
      >like 0 and 100
      >and the number of x's is arbitrary as well in this example 10 x's are
      >present.
      >
      >x,x,x,x,x,x,x, x,x,x
      >
      >I want to find all possible combinations for this. In the end I would have
      >a list of all possible combinations of the x's in groups of ten whre each x
      >would be a number between 0 and 100.[/color]

      If you have a list of numbers that you would like to make permutations
      of, std::next_permu tation() will do the job for you. If you want to
      count up every X from 0 to 100 you'll have to do that yourself, but it's
      easy.

      --
      Be seeing you.

      Comment

      • Roger B.

        #4
        Re: Permutation lists?? Really Need Help

        That is not it. Not all numbers from 1 to 100 could be used in a group of
        10 x's. And Numbers could be repeated in the group of 10's. I need all
        combinations. And there are to many to find by hand, plus to do it by hand
        would end up being very confusing after a while. This is not just a count
        up of loops or what else. It is a lot more complicated than that.

        PS. TO BUSTER COPLEY - I don't bullsh** on my posts . It is a personal
        interest project. And I have worked on it for about 5 hours. Thank You.
        "Thore B. Karlsen" <sid@6581.com > wrote in message
        news:g5k4nv4vpn gp5rdrtdo1qcdea n82hktcff@4ax.c om...[color=blue]
        > On Thu, 25 Sep 2003 01:44:04 GMT, "Roger B." <rogerab22@hotm ail.com>
        > wrote:
        >[color=green]
        > >Hello,
        > >
        > > I am working on a personal interest project and have been racking my[/color][/color]
        brain[color=blue][color=green]
        > >on this problem for about 5 hours total now, and tracking through old
        > >newsgroup posts but haven't figuried it out yet so heres my question.
        > >
        > >I want to be able to make a list of all possible combinations (repitiions
        > >are allowed) of numbers where X is a arbitrary initeger between something
        > >like 0 and 100
        > >and the number of x's is arbitrary as well in this example 10 x's are
        > >present.
        > >
        > >x,x,x,x,x,x,x, x,x,x
        > >
        > >I want to find all possible combinations for this. In the end I would[/color][/color]
        have[color=blue][color=green]
        > >a list of all possible combinations of the x's in groups of ten whre each[/color][/color]
        x[color=blue][color=green]
        > >would be a number between 0 and 100.[/color]
        >
        > If you have a list of numbers that you would like to make permutations
        > of, std::next_permu tation() will do the job for you. If you want to
        > count up every X from 0 to 100 you'll have to do that yourself, but it's
        > easy.
        >
        > --
        > Be seeing you.[/color]


        Comment

        • Alf P. Steinbach

          #5
          Re: Permutation lists?? Really Need Help

          [Please do not (repeated for your convenience, DO NOT) top-post, rearranged:]

          On Thu, 25 Sep 2003 02:50:43 GMT, "Roger B." <rogerab22@hotm ail.com> wrote:
          [color=blue]
          >"Thore B. Karlsen" <sid@6581.com > wrote in message
          >news:g5k4nv4vp ngp5rdrtdo1qcde an82hktcff@4ax. com...[color=green]
          >> On Thu, 25 Sep 2003 01:44:04 GMT, "Roger B." <rogerab22@hotm ail.com>
          >> wrote:
          >>[color=darkred]
          >> >Hello,
          >> >
          >> > I am working on a personal interest project and have been racking my[/color][/color]
          >brain[color=green][color=darkred]
          >> >on this problem for about 5 hours total now, and tracking through old
          >> >newsgroup posts but haven't figuried it out yet so heres my question.
          >> >
          >> >I want to be able to make a list of all possible combinations (repitiions
          >> >are allowed) of numbers where X is a arbitrary initeger between something
          >> >like 0 and 100
          >> >and the number of x's is arbitrary as well in this example 10 x's are
          >> >present.
          >> >
          >> >x,x,x,x,x,x,x, x,x,x
          >> >
          >> >I want to find all possible combinations for this. In the end I would[/color][/color]
          >have[color=green][color=darkred]
          >> >a list of all possible combinations of the x's in groups of ten whre each[/color][/color]
          >x[color=green][color=darkred]
          >> >would be a number between 0 and 100.[/color]
          >>
          >> If you have a list of numbers that you would like to make permutations
          >> of, std::next_permu tation() will do the job for you. If you want to
          >> count up every X from 0 to 100 you'll have to do that yourself, but it's
          >> easy.[/color][/color]

          Thore, you're mean.

          [color=blue]
          >That is not it. Not all numbers from 1 to 100 could be used in a group of
          >10 x's. And Numbers could be repeated in the group of 10's. I need all
          >combinations . And there are to many to find by hand, plus to do it by hand
          >would end up being very confusing after a while. This is not just a count
          >up of loops or what else. It is a lot more complicated than that.[/color]

          Have you considered, as Buster Copley did for you, the number of
          combinations?

          It may be that he misunderstood you, but the spirit of the argument
          was sound; the list will be _long_, and it's generated by simple
          counting (in the decimal system if you have ten unique values).



          [color=blue]
          >PS. TO BUSTER COPLEY - I don't bullsh** on my posts . It is a personal
          >interest project. And I have worked on it for about 5 hours. Thank You.[/color]

          It seems impossible that you worked on it for even 1 minute.

          Anyway, it doesn't have much to do with C++.

          So replies to this posting are redirected to [comp.programmin g], which
          I think is where you should have posted your problem in the first
          place.

          Hth.


          XFUT: [comp.programmin g].

          Comment

          • Buster Copley

            #6
            Re: Permutation lists?? Really Need Help

            Enjoy!

            #include <iostream>
            #include <vector>

            typedef std::vector <int>::size_typ e sz_t;
            typedef unsigned digit_t;

            const sz_t size = 10;
            const digit_t modulus = 101;

            std::ostream &
            operator << (std::ostream & s, const std::vector <digit_t> & v)
            {
            for (sz_t i = 0, n = v.size (); i != n; ++ i)
            (i ? (s << ", ") : s) << v [i];
            return s;
            }

            int main ()
            {
            std::vector <digit_t> v (size);
            while (v.back () != modulus)
            {
            std::cout << v << '\n';
            ++ v.front ();
            for (sz_t i = 0; i != size - 1; ++ i) if (v [i] == modulus)
            {
            v [i] = 0;
            ++ v [i + 1];
            }
            }
            }

            Comment

            • Sam Holden

              #7
              Re: Permutation lists?? Really Need Help

              On Thu, 25 Sep 2003 02:50:43 GMT, Roger B. <rogerab22@hotm ail.com> wrote:[color=blue]
              > That is not it. Not all numbers from 1 to 100 could be used in a group of
              > 10 x's. And Numbers could be repeated in the group of 10's. I need all
              > combinations. And there are to many to find by hand, plus to do it by hand
              > would end up being very confusing after a while. This is not just a count
              > up of loops or what else. It is a lot more complicated than that.[/color]

              You make no sense. The suggested solution is the normal way to
              generate permutations and combinations. Writing code to do it
              instead of a pen and paper is trivial enough.

              --
              Sam Holden

              Comment

              • Thore B. Karlsen

                #8
                Re: Permutation lists?? Really Need Help

                On Thu, 25 Sep 2003 02:50:43 GMT, "Roger B." <rogerab22@hotm ail.com>
                wrote:
                [color=blue]
                >That is not it. Not all numbers from 1 to 100 could be used in a group of
                >10 x's. And Numbers could be repeated in the group of 10's. I need all
                >combinations . And there are to many to find by hand, plus to do it by hand
                >would end up being very confusing after a while. This is not just a count
                >up of loops or what else. It is a lot more complicated than that.[/color]

                I honestly don't know what you're looking for. Do you want to do:

                0,0,0,0,0,0,0,0 ,0,0
                0,0,0,0,0,0,0,0 ,0,1
                0,0,0,0,0,0,0,0 ,0,2

                etc.

                Or do you want to start with a list like this:

                0,1,2,3,4,5,6,7 ,8,9

                and generate all the combinations of those given numbers.

                The first case is very easy to code, but will take a lifetime to finish
                if you want to go through all of them. For the second case, use
                std::next_permu tation().

                --
                Be seeing you.

                Comment

                • Gavin Deane

                  #9
                  Re: Permutation lists?? Really Need Help

                  "Roger B." <rogerab22@hotm ail.com> wrote in message news:<7Kscb.575 053$uu5.94602@s ccrnsc04>...

                  <please don't top-post, thank you - rearranged>
                  [color=blue][color=green]
                  > > On Thu, 25 Sep 2003 01:44:04 GMT, "Roger B." <rogerab22@hotm ail.com>
                  > > wrote:
                  > >[color=darkred]
                  > > >Hello,
                  > > >
                  > > > I am working on a personal interest project and have been racking my[/color][/color]
                  > brain[color=green][color=darkred]
                  > > >on this problem for about 5 hours total now, and tracking through old
                  > > >newsgroup posts but haven't figuried it out yet so heres my question.
                  > > >
                  > > >I want to be able to make a list of all possible combinations (repitiions
                  > > >are allowed) of numbers where X is a arbitrary initeger between something
                  > > >like 0 and 100
                  > > >and the number of x's is arbitrary as well in this example 10 x's are
                  > > >present.
                  > > >
                  > > >x,x,x,x,x,x,x, x,x,x
                  > > >
                  > > >I want to find all possible combinations for this. In the end I would[/color][/color]
                  > have[color=green][color=darkred]
                  > > >a list of all possible combinations of the x's in groups of ten whre each[/color][/color]
                  > x[color=green][color=darkred]
                  > > >would be a number between 0 and 100.[/color]
                  > >
                  > > If you have a list of numbers that you would like to make permutations
                  > > of, std::next_permu tation() will do the job for you. If you want to
                  > > count up every X from 0 to 100 you'll have to do that yourself, but it's
                  > > easy.[/color]
                  >
                  > That is not it. Not all numbers from 1 to 100 could be used in a group of
                  > 10 x's. And Numbers could be repeated in the group of 10's. I need all
                  > combinations. And there are to many to find by hand, plus to do it by hand
                  > would end up being very confusing after a while. This is not just a count
                  > up of loops or what else. It is a lot more complicated than that.[/color]

                  I'm still not sure of the question. Is what Buster Copley posted not
                  what you're after? Before writing any C++ code, you will need to
                  precisely and fully understand how you would solve the problem on
                  paper, given enough time. If you've got that far, have you got any
                  code you're having problems with?

                  The standard advice is to break the problem into simple steps and
                  implement them one at a time. Without understanding the problem it's
                  difficult to try and suggest where to start.

                  GJD

                  Comment

                  • Jerry Coffin

                    #10
                    Re: Permutation lists?? Really Need Help

                    In article <ELrcb.568905$H o3.104820@sccrn sc03>, rogerab22@hotma il.com
                    says...[color=blue]
                    > Hello,
                    >
                    > I am working on a personal interest project and have been racking my brain
                    > on this problem for about 5 hours total now, and tracking through old
                    > newsgroup posts but haven't figuried it out yet so heres my question.
                    >
                    > I want to be able to make a list of all possible combinations (repitiions
                    > are allowed) of numbers where X is a arbitrary initeger between something
                    > like 0 and 100
                    > and the number of x's is arbitrary as well in this example 10 x's are
                    > present.
                    >
                    > x,x,x,x,x,x,x,x ,x,x
                    >
                    > I want to find all possible combinations for this. In the end I would have
                    > a list of all possible combinations of the x's in groups of ten whre each x
                    > would be a number between 0 and 100.[/color]

                    Try a different approach. Storage alone for this is prohibitive for any
                    practical purpose -- if you stored your list formatted as you've shown
                    it above (i.e. numbers converted to text, commas in between them) you're
                    looking at approximately 3 terabytes of storage. If you store the data
                    in a fairly obvious binary form, you can get that down to roughly 1
                    terabyte, but even that's still ridiculous.

                    Thus the advice to find a different approach -- this one is a problem,
                    not a solution.

                    --
                    Later,
                    Jerry.

                    The universe is a figment of its own imagination.

                    Comment

                    • Karl Heinz Buchegger

                      #11
                      Re: Permutation lists?? Really Need Help



                      "Roger B." wrote:[color=blue]
                      >
                      > That is not it. Not all numbers from 1 to 100 could be used in a group of
                      > 10 x's.[/color]

                      Why not?
                      [color=blue]
                      > And Numbers could be repeated in the group of 10's.[/color]

                      Good.
                      [color=blue]
                      > I need all
                      > combinations. And there are to many to find by hand, plus to do it by hand
                      > would end up being very confusing after a while.[/color]

                      Sure, that's why a computer is perfect for this. But nevertheless (maybe
                      using smaller numbers), doing it by hand gives a good grasp at what the
                      program is supposed to do.
                      [color=blue]
                      > This is not just a count
                      > up of loops or what else.[/color]

                      Basically: Yes it is. But how the loops look in specific and/or if
                      maybe recursion is part of your soultion can only be decided if we
                      understand your requirement.
                      [color=blue]
                      > It is a lot more complicated than that.[/color]

                      I'm sure it is not complicated.
                      The problem is, that nobody seems to understand your requirement
                      completely. Thus we don't know what to suggest.

                      Could you try to rephrase it?
                      Also make sure we understand what is variable in your assignment
                      and what is constant. As said: Choose smaller numbers and show
                      an example. That helps a lot in understanding your problem.


                      --
                      Karl Heinz Buchegger
                      kbuchegg@gascad .at

                      Comment

                      • J. Campbell

                        #12
                        Re: Permutation lists?? Really Need Help

                        "Roger B." <rogerab22@hotm ail.com> wrote in message news:<ELrcb.568 905$Ho3.104820@ sccrnsc03>...[color=blue]
                        > Hello,
                        >
                        > I am working on a personal interest project and have been racking my brain
                        > on this problem for about 5 hours total now, and tracking through old
                        > newsgroup posts but haven't figuried it out yet so heres my question.
                        >
                        > I want to be able to make a list of all possible combinations (repitiions
                        > are allowed) of numbers where X is a arbitrary initeger between something
                        > like 0 and 100
                        > and the number of x's is arbitrary as well in this example 10 x's are
                        > present.
                        >
                        > x,x,x,x,x,x,x,x ,x,x
                        >
                        > I want to find all possible combinations for this. In the end I would have
                        > a list of all possible combinations of the x's in groups of ten whre each x
                        > would be a number between 0 and 100.
                        >
                        > Thanks for any help.[/color]


                        This will work. However, don't wait up all night for the output.
                        Were you to save this to a file, it would fill up a world's worth of
                        hard-drives!!!

                        #include <iostream>
                        #include <fstream>

                        using namespace std;

                        int main(){
                        int a,b,c,d,e,f,g,h ,i,j;
                        int max = 100;
                        for(a=0;a<max;+ +a){
                        for(b=0;b<max;+ +b){
                        for(c=0;c<max;+ +c){
                        for(d=0;d<max;+ +d){
                        for(e=0;e<max;+ +e){
                        for(f=0;f<max;+ +f){
                        for(g=0;g<max;+ +g){
                        for(h=0;h<max;+ +h){
                        for(i=0;i<max;+ +i){
                        for(j=0;j<max;+ +j){
                        cout <<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "
                        <<f<<" "<<g<<" "<<h<<" "<<i<<" "<<j<<endl;
                        }}}}}}}}}}
                        }

                        Comment

                        • Agent Mulder

                          #13
                          Re: Permutation lists?? Really Need Help

                          <Roger B>[color=blue]
                          > That is not it. Not all numbers from 1 to 100 could be used in a group of
                          > 10 x's. And Numbers could be repeated in the group of 10's. I need all
                          > combinations. And there are to many to find by hand, plus to do it by hand
                          > would end up being very confusing after a while. This is not just a count
                          > up of loops or what else. It is a lot more complicated than that.[/color]
                          </>

                          I still don't understand it. Is it the famous lion-cage in disguise? You have,
                          say, 100 cages and 10 fierce lions. Each lion must have a cage on its own.
                          How many ways are there to cage the lions? Is that the question? What do
                          you try to solve? Write out 10 lines by hand so that I can see what you're
                          after.

                          -X


                          Comment

                          • D.F.S.

                            #14
                            Re: Permutation lists?? Really Need Help


                            "Roger B." <rogerab22@hotm ail.com> wrote in message
                            news:ELrcb.5689 05$Ho3.104820@s ccrnsc03...
                            [snip][color=blue]
                            > I want to be able to make a list of all possible combinations[/color]
                            (repitiions[color=blue]
                            > are allowed) of numbers where X is a arbitrary initeger between[/color]
                            something[color=blue]
                            > like 0 and 100[/color]

                            are you thinking of (pared down example, five numbers two at a time)?
                            1,1 2,2 3,3 4,4 5,5
                            1,2 2,3 3,4 4,5
                            1,3 2,4 3,5
                            1,4 2,4
                            1,5

                            Are you thinking along the line where order does not matter. 3 is only
                            paired with 5 once.
                            Are you trying to generate this sequence, or predict the predict the
                            number of unique
                            combinations?

                            /*MAJOR clue here, Note that the number on the right is always equal
                            to or greater than
                            the number on the left. This makes 3, 5 legal but not 5, 3*/

                            if you just want to count them... n =Number of numbers, k =How many in
                            each group

                            (n + k - 1)!
                            -----------
                            k! * (n- 1)!

                            Comment

                            Working...