Forums Register Login

Permutations - upper case and lower case

+Pie Number of slices to send: Send
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

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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...
Cob is sand, clay and sometimes straw. This tiny ad is made of cob:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1467 times.
Similar Threads
wordings for error message
compare strings case insensitive?
Case Insensative search
isAlpha?
Formatter Sytax to convert UPPER to lower
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 02:38:42.