Public
Edited
Jul 10, 2023
Insert cell
Insert cell
input = {
// let's start by imagining that we're only going to have a 9-bit wide input; eventually we'll bump it up to 255 (or more?) but for now we just want to demonstrate. This is our input buffer
const input = 1n << 4n;
// here's how you can output binary strings:
console.log(input.toString(2));
return input;
}
Insert cell
table = {
// each rule is an 8-bit integer representing the transition rule for a 3-bit segment of the input.
// I'm not sure how it is supposed to work, but I'm guessing it's supposed to represent the possibilities
// in a lexicographically-ordered permutation of 3 bits: 000, 001, 010, 011, 100, 101, 110, 111
// (or is it reversed by convention?)
const rule = 30n;
// I'm sure there's a clever way to build this table, but for a moment, let's be dumb. Anything non-zero means true
const table = new Map();
table.set(0n, rule & 128n);
table.set(1n, rule & 64n);
table.set(2n, rule & 32n);
table.set(3n, rule & 16n);
table.set(4n, rule & 8n);
table.set(5n, rule & 4n);
table.set(6n, rule & 2n);
table.set(7n, rule & 1n);

return table;
}
Insert cell
Insert cell
next(input, table, 9n)
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more