permutations II

B

Bill Cunningham

[snip]
I believe you can code it that way. If you are interested, I can post the
source.

I would much appreciate it. I do what to work with char permutations.
Takes the word "zeus". There's going to have to be a counter somewhere I do
understand that concept. Coding it is different.

Bill
 
B

Ben Bacarisse

Bill Cunningham said:
"Ben Bacarisse" <[email protected]> wrote in message

I don't think so. I don't know how to code it. I'm thinking
using for?

You'd need some loop/loops but I think you should probably try a
simpler problem first. Where do you get these problems from? Do you
finish any of them?
 
G

Guest

define "read the number of characters"
define "sift them around"

<snip>

    I think I need a char** definition here. Maybe I could replace CHAR_MAX
with 40 or something like that. I'll post something soon that I believe
might get me closer.

you didn't give a definition of the two terms
 
C

Carl B. Edwinson

Richard said:
Bill Cunningham said:


No, it's ISO C - or at least, nearly so.

I made the following adjustments:

1) added a newline to the end of the file;
2) changed two format specifiers from %s to %d for __LINE__
printing.

I then got a reasonably clean build, which works just fine, although
the usage instructions are wrong. On the command line, pass the
length of the desired output as the first command line argument,
and a series of one or more characters as the second command line
argument. (The instructions have this the wrong way around.)

For example, if you specify 3 abcd as the command line arguments
(after the program name), you get this output (which I've piped
through fmt to reduce vertical space requirements):

aaa baa caa daa aba bba cba dba aca bca cca dca ada bda cda dda
aab bab cab dab abb bbb cbb dbb acb bcb ccb dcb adb bdb cdb ddb
aac bac cac dac abc bbc cbc dbc acc bcc ccc dcc adc bdc cdc ddc
aad bad cad dad abd bbd cbd dbd acd bcd ccd dcd add bdd cdd ddd


Sorry about that. I've only had 1 year of C under my belt. This code
was a snippet from a password cracker I was working on. The benefit of
this permutation is that you can start permuting from any point in the
array. So, the idea is to permute the next value, and then let each
thread of the program permute the rest of the elements.

Oh, this was for CUDA, which puts an extremely high price on branching
instuctions. Since each thread will do nearly the exact same thing, the
code is ideal for it. Also, notice that no modulus was used.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top