Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

generate permutations

NatalyNataly Member Posts: 1
Hi all!
If someone knows how to generate permutations on different kind of objects... OK, the name for it is not "permutations", but I don't know how to name it in English.
For example, I have 2 objects: bool and int. Let us assume that bool can be one of 2 values: {true, false}, int can be one of 3 values: {0,1,2}.
So the permutations that I have to obtain are:

true, 0
true, 1
true, 2
false, 0
false, 1
false, 2

If someone knows how to do it - please help me! It's very urgent!

Thank you!

Comments

  • zibadianzibadian Member Posts: 6,349
    : Hi all!
    : If someone knows how to generate permutations on different kind of
    : objects... OK, the name for it is not "permutations", but I don't
    : know how to name it in English.
    : For example, I have 2 objects: bool and int. Let us assume that bool
    : can be one of 2 values: {true, false}, int can be one of 3 values:
    : {0,1,2}.
    : So the permutations that I have to obtain are:
    :
    : true, 0
    : true, 1
    : true, 2
    : false, 0
    : false, 1
    : false, 2
    :
    : If someone knows how to do it - please help me! It's very urgent!
    :
    : Thank you!
    :
    Here's the pseudocode for this:
    [code]
    for (i = false to true)
    for (j = 0 to 2)
    Set object (i, j)
    endfor
    endfor
    [/code]
Sign In or Register to comment.