![]() |
|
Code Golf Challenge #1 - Thue-Morse Sequence - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Coding (https://sinister.li/Forum-Coding--71) +--- Thread: Code Golf Challenge #1 - Thue-Morse Sequence (/Thread-Code-Golf-Challenge-1-Thue-Morse-Sequence) |
RE: Code Golf Challenge #1 - Thue-Morse Sequence - Shebang - 08-21-2015 Well, the 7-day time limit is up, and the winner is @"Stocking"! Congrats! Reference Python solution (49 Bytes): Code: f=lambda n:[bin(x).count('1')%2for x in range(n)]Reference Stuck solution (11 Bytes): Code: ir"2bc+2%":RE: Code Golf Challenge #1 - Thue-Morse Sequence - 0xDEAD10CC - 09-03-2015 Not necessarily any attempt at golf but here is an entry in C: Code: #include <stdio.h>
#define MAX_OUT 200
int main(void)
{
int i = 1, j, k;
char buf[MAX_OUT + 1] = { 0 };
buf[0] = '0';
for (;;)
{
k = i;
for (j = 0; j < k; ++j)
{
buf[i] = buf[j] ^ 1;
if (++i == MAX_OUT) goto end;
}
}
end:
buf[MAX_OUT] = 0;
puts(buf);
return 0;
} |