rule-30

1.0.0 • Public • Published

rule-30 npm version

Returns new binary state of array after applying cellular automaton Rule 30

Install

npm install rule-30

Usage

/*
Pass in binary array of length n (e.g. [0, 1, 0, 0]). Function returns an array of length n+2 after applying Rule 30.
pattern:                   111  110  101  100  011  010  001  000
new state of center value:  0    0    0    1    1    1    1    0
*/

var rule30 = require('rule-30');
console.log( rule30([0, 0, 1, 0, 1]) ) // [0, 0, 1, 1, 0, 1, 0]

API

rule30([array of 1s and 0s])

License

MIT

Package Sidebar

Install

npm i rule-30

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jylopez