If order doesn't matter, you can try Linq. We list all binary numbers in the range [0..2**word.Length] . and treat each number as a mask: 0 - lower case, 1 - upper case. FDor instance for happy we have
mask string ---------------- 00000 -> happy 00001 Happy 00010 hAppy 00011 HAppy 00100 haPpy 00101 HaPpy ... 11111 HAPPY
Code:
using System.Linq; ... List<string> permutate(string word) => Enumerable .Range(0, 1 << word.Length) .Select(mask => string.Concat(word.Select((c, i) => (mask & (1 << i)) == 0 ? c : char.ToUpper(c)))) .ToList();
Demo version:
Console.Write(string.Join(", ", permutate("happy")));
Result:
happy, Happy, hAppy, HAppy, haPpy, HaPpy, hAPpy, HAPpy, hapPy, HapPy, hApPy, HApPy, haPPy, HaPPy, hAPPy, HAPPy, happY, HappY, hAppY, HAppY, haPpY, HaPpY, hAPpY, HAPpY, hapPY, HapPY, hApPY, HApPY, haPPY, HaPPY, hAPPY, HAPPY