Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,19 @@
void main() {
import std.stdio, std.algorithm;
enum nGenerations = 10;
enum initial = "0011101101010101001000";
enum table = "00010110";
char[initial.length + 2] A = '0', B = '0';
A[1 .. $-1] = initial;
foreach (immutable _; 0 .. nGenerations) {
foreach (immutable i; 1 .. A.length - 1) {
write(A[i] == '0' ? '_' : '#');
const val = (A[i-1]-'0' << 2) | (A[i]-'0' << 1) | (A[i+1]-'0');
B[i] = table[val];
}
A.swap(B);
writeln;
}
}

View file

@ -0,0 +1,13 @@
void main() {
import std.stdio, std.algorithm, std.range;
auto A = "_###_##_#_#_#_#__#__".map!q{a == '#'}.array;
auto B = A.dup;
do {
A.map!q{ "_#"[a] }.writeln;
A.zip(A.cycle.drop(1), A.cycle.drop(A.length - 1))
.map!(t => [t[]].sum == 2).copy(B);
A.swap(B);
} while (A != B);
}

View file

@ -0,0 +1,24 @@
void main() {
import std.stdio, std.algorithm, std.range, std.bitmanip;
immutable initial = "__###_##_#_#_#_#__#___";
enum nGenerations = 10;
BitArray A, B;
A.init(initial.map!(c => c == '#').array);
B.length = initial.length;
foreach (immutable _; 0 .. nGenerations) {
//A.map!(b => b ? '#' : '_').writeln;
//foreach (immutable i, immutable b; A) {
foreach (immutable i; 1 .. A.length - 1) {
"_#"[A[i]].write;
immutable val = (uint(A[i - 1]) << 2) |
(uint(A[i]) << 1) |
uint(A[i + 1]);
B[i] = val == 3 || val == 5 || val == 6;
}
writeln;
A.swap(B);
}
}