aspose file tools*
The moose likes Java in General and the fly likes Permutations - upper case and lower case Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Permutations - upper case and lower case" Watch "Permutations - upper case and lower case" New topic
Author

Permutations - upper case and lower case

Liza Zapson
Greenhorn

Joined: Mar 17, 2011
Posts: 1
I'm trying to create a string of upper and lower case characters. Where the letters in the string stay in the same position. For example if the sting is ABC the result would be the following.

abc
ABC
Abc
ABc
aBc
aBC
abC
AbC

Any thoughts would be appreciated. Thanks, Lisa

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39845
    
  28
Welcome to the Ranch

Write down how you are going to do it. I suggest you try a recursion:

write the first letter-write the second letter-change the second letter-back

But that is only a small part of it.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11479
    
  16

Liza Zapson wrote:
abc
ABC
Abc
ABc
aBc
aBC
abC
AbC

It may be of interest to notice that since the letters don't change, the only thing that matters is the case'. so what you have could also be conveyed as

LLL
UUU
ULL
UUL
LUL
LUU
LLU
ULU

I could replace these with numbers....L=0, U=1...

000
111
100
110
010
011
001
101

and then re-arrange those into

000
001
010
011
100
101
110
111

Maybe this give you an idea how to proceed...


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Permutations - upper case and lower case