27
Who needs to compare things case insensitively when you're able to generate every permutation of uppercase and lowercase? No one! That's the answer. No one does. Your task is to achieve this feat; generate all possible permutations of uppercase/lowercase for a given input.
Input
A string of printable standard ascii characters. Input should not be assumed to be all lowercase. Input will always be at least one character.
Output
Every permutation of uppercase and lowercase for the inputted string (no duplicates). This should only change characters with a small and large version (numbers will stay the same). Each permutation must be output as a string or a list of characters; lists of singleton strings are not allowed.
Examples
a1a
['a1a', 'a1A', 'A1a', 'A1A']
abc
['abc', 'abC', 'aBc', 'aBC', 'Abc', 'AbC', 'ABc', 'ABC']
Hi!
['hi!', 'hI!', 'Hi!', 'HI!']
Scoring
This is code-golf, so the shortest answer (in bytes) wins.
As a fun extra see how much additional effort it will take to handle the extended ascii characters, here is an extra test case:
ž1a -> ['ž1a', 'ž1A', 'Ž1a', 'Ž1A']
(your program does not need to support this)
10Interesting Unicode test case:
Σ
→['Σ', 'σ', 'ς']
– n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ – 2016-06-01T03:20:35.527Can we use a list of characters instead of a string? For example, if
Hi!
gave{('H', 'i', '!'), ('h', 'I', '!'), ('h', 'i', '!'), ('H', 'I', '!')}
would that be acceptable? – James – 2016-06-01T06:21:45.213@DrGreenEggsandHamDJ List of characters are allowed by default. In Python, those are singleton strings though, which is different.
– Dennis – 2016-06-01T07:01:54.130@DrGreenEggsandHamDJ I would tend to agree with Dennis here. I didn't want to be too specific in the spec in order to not inadvertently exclude languages based on their output and wanted to make sure something like a list of characters was allowed. However I don't think singleton strings fit the bill in this case. – Poke – 2016-06-01T13:21:02.780
1@n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ even more interesting is that
Σ
is the uppercase version at the beginning of a word,σ
is the lowercase version at the beginning or in the middle but not the end of a word, andς
is the lowercase version at only the end of a word. – FantaC – 2017-12-14T15:23:25.877I know this is pretty old but when outputting strings, is it acceptable to output a trailing space at the end of the line? – Dom Hastings – 2018-05-01T19:06:24.833
1@DomHastings As in you have a list and you're just space-delimiting the output? That seems reasonable to me. – Poke – 2018-05-01T19:42:44.923