File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Permutations - upper case and lower case

 
Liza Zapson
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 12015
24
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic