#Java, 209 207 195 191 bytes
Java, 209 207 195 191 bytes
I'm surprised I was able to get it this short. There is probably still room for improvement. As usual, suggestions will be appreciated :)
This returns a char[]
. Call using a(n)
.
char[]a;int b,c,d,e=2;char[]a(int f){java.util.Arrays.fill(a=new char[b=1<<f],'.');for(a[0]=88;d+1<e;c=(d+e)/2,a[c%b]=88)e=b(d=b(b(c)));return a;}int b(int f){for(;;)if(a[++f%b]>87)return f;}
Indented:
char[] a;
int b, c, d, e = 2;
char[] a(int f){
java.util.Arrays.fill(
a = new char[
b = 1 << f
]
, '.'
);
for(
a[0] = 88;
d + 1 < e;
c = (d + e) / 2,
a[c % b] = 88
)
e = b(
d = b(
b(c)
)
);
return a;
}
int b(int f){
for (;;)
if (a[++f % b] > 87)
return f;
}
12 bytes thanks to Peter :)
4 bytes thanks to TNT ;)