Results 1 to 8 of 8
- 08-05-2011, 07:17 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 9
- Rep Power
- 0
Need a help in two dimentaional permutation
Hi!
I need help writing java code for the following permutations....
Input : a=(0,32)
b=(32,64)
Lenghth: 3 (Means 2 power 3 i need 8 combinations)
output:
0 32
0 32
0 32
0 32
0 32
32 64
0 32
32 64
32 64
32 64
0 32
0 32
32 64
32 64
32 64
0 32
32 64
0 32
32 64
0 32
32 64
32 64
32 64
0 32
- 08-05-2011, 07:22 AM #2
It is difficult to offer advice when I don't have a friggin clue what the code is supposed to do.
However, what you need to do is grab some paper and write down clear and precise steps of how to generate that desired output. Once you have done that, writing the code should be simple.
- 08-05-2011, 07:57 AM #3
- Join Date
- Dec 2010
- Location
- Stockholm, Sweden
- Posts
- 222
- Blog Entries
- 9
- Rep Power
- 3
Yeaahh, that does not look like a permutation, I think you need to clarify the output, what is it, is it two row nationation, one row notation, [god forbid in this case] cycle notation? What are we dealing with?
Also clarify a and b while you are on that.
Edit:
Ohh, a and b are obviously the elements, sorry.Last edited by Hibernate; 08-05-2011 at 08:00 AM.
Ex animo! Hibernate
Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.
- 08-05-2011, 08:07 AM #4
- Join Date
- Dec 2010
- Location
- Stockholm, Sweden
- Posts
- 222
- Blog Entries
- 9
- Rep Power
- 3
Deciphering this I suppose you intended[!] to write:
(And thank "God" that is a permutation!)Java Code:⎛aaa aab aba abb baa bab bba bbb⎞ ⎝aaa aab abb baa bbb aba bab bba⎠
Last edited by Hibernate; 08-05-2011 at 08:17 AM.
Ex animo! Hibernate
Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.
- 08-05-2011, 08:10 AM #5
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
@OP: do you mean all sequences of length 3 made up of a and b? Ie aaa, aab, abb, baa, bbb, aba, bab, bba?
If so - or in any case - Junky's advice is good. Think about how you would list all 8=2^3 sequences. Your list seems to be ordered somewhat randomly (to my eye). I might have chosen something with a pattern so I was sure not to leave any out: aaa, aab, aba, abb, baa, bab, bba, bbb.
- 08-05-2011, 08:15 AM #6
- Join Date
- Dec 2010
- Location
- Stockholm, Sweden
- Posts
- 222
- Blog Entries
- 9
- Rep Power
- 3
I would suggest decoding into integers (aaa = 0, aab = 1, aba = 2, …) and just use a look-up-table and return the return value encoded:
Java Code:final int[] π = {0, 1, 3, 4, 7, 2, 5, 6}; //as a static (constant) variable in the class output = encode(π[decode(input)]);Last edited by Hibernate; 08-05-2011 at 08:31 AM. Reason: whoops, typo two 4:s [whoops, typo in typo note]
Ex animo! Hibernate
Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.
- 08-05-2011, 10:39 AM #7
Member
- Join Date
- Feb 2011
- Posts
- 9
- Rep Power
- 0
Yes Pbrockway2 ... I need to write program for 2^3 sequence of double digit number ....please help
- 08-06-2011, 01:28 AM #8
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Did you try follow Junky's advice and try and make clear the steps you (rather than a computer) would follow? After all you must have done something to arrive at the sequence in your original post. If so what results did you get?
Did you think about the particular pattern to the sequence I suggested as an alternative (and which Hibernate used)? Is there some way that loops (or other programming constructs you have seen) could be used to generate that pattern? Have you seen patterns like this elsewhere?
Similar Threads
-
Permutation
By Claymz in forum New To JavaReplies: 4Last Post: 06-01-2011, 02:27 PM -
Mapping of variables to values (permutation with repetition?)
By electra in forum Advanced JavaReplies: 3Last Post: 08-24-2009, 07:39 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks