0

Hello. I have tried numerous string permutation methods, and they work, but not for what I need. I need to permute a string such that I don't get any reversals:

abcd
abdc
acbd
acdb
adbc
adcb *
bacd
badc
bcad
bcda *

see how these are reversals of each other? this is the first few lines of output when I try to permute "abcd". Unfortunately I can't think of an algorithm to skip over any reversals. Thanks

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by NormR1
0

How are you saving the generated Strings? Could you also save its reversed contents in a list to test against?

0

How are you saving the generated Strings? Could you also save its reversed contents in a list to test against?

well, I send each to another method that generates a number based off the string and adds it to the total. the thing is, I get duplicate numbers (because things like abcde and edcba result in the same number). Plus, I need to be able to go up to 19 or 20 factorial, and it would really help if the number of cases I need to check was cut in half.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.