On Tuesday, 12 December 2023 at 16:21:46 UTC, Kevin Bailey wrote:
On Tuesday, 12 December 2023 at 15:20:23 UTC, Paul Backus wrote:
But unfortunately, the code shown now prints 120 lines of:
baaaa
120 being suspiciously equal to 5!. The documentation[2] seems
to imply that this should be:
baaaa
abaaa
...
This code works for me. (The last 20+ lines are `aaaab`):
```d
import std;
void main() {
char[] as = replicate(['a'], 5);
as[0] = 'b';
foreach (perm; as.byChar.permutations)
writeln(perm);
}
```
Try it on https://run.dlang.io/. Maybe there's some issue on your
machine?
Also if you use `string as = "abcde";` you can see the
permutations better.