return function() { let min = Math.min; var max = Math.max; var huge = Number.MAX_SAFE_INTEGER; let self = { state: { strings: [], slots: {} } }; self._ = [0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0] function match(self, _) { console.log(Object.entries(_).filter(([,v])=>v>0).map(([k,v]) => `${k} :: ${v}`).join('\n') ); console.log(self.state.strings); console.log(self.state.slots); if (_[0] > 0 && _[1] > 0) { let acc = min(_[0],_[1]) _[0] = max(_[0] - acc, 0); _[1] = max(_[1] - acc, 0); return true; } if (_[2] > 0 && _[3] > 0) { let acc = min(_[2],_[3]) _[2] = max(_[2] - acc, 0); _[3] = max(_[3] - acc, 0); return true; } if (_[4] > 0 && _[5] > 0) { let acc = min(_[4],_[5]) _[4] = max(_[4] - acc, 0); _[5] = max(_[5] - acc, 0); _[3] += acc * 1; _[4] += acc * 1; return true; } if (_[4] > 0 && _[6] > 0) { let acc = min(_[4],_[6]) _[4] = max(_[4] - acc, 0); _[6] = max(_[6] - acc, 0); _[2] += acc * 1; return true; } if (_[7] > 0 && _[8] > 0) { let acc = min(_[7],_[8]) _[7] = max(_[7] - acc, 0); _[8] = max(_[8] - acc, 0); _[1] += acc * 1; _[7] += acc * 1; return true; } if (_[7] > 0 && _[9] > 0) { let acc = min(_[7],_[9]) _[7] = max(_[7] - acc, 0); _[9] = max(_[9] - acc, 0); _[0] += acc * 1; return true; } if (_[10] > 0) { let acc = _[10]; _[10] = max(_[10] - acc, 0); _[11] += acc * 1; _[12] += acc * 1; _[13] += acc * 1; _[14] += acc * 1; _[15] += acc * 1; return true; } if (_[11] > 0) { let acc = _[11]; _[11] = max(_[11] - acc, 0); _[16] += acc * 1; return true; } if (_[12] > 0) { let acc = _[12]; _[12] = max(_[12] - acc, 0); _[17] += acc * 1; _[18] += acc * 1; return true; } if (_[19] > 0) { let acc = _[19]; _[19] = max(_[19] - acc, 0); _[20] += acc * 1; return true; } if (_[13] > 0 && _[21] > 0) { let acc = min(_[13],_[21]) _[13] = max(_[13] - acc, 0); _[21] = max(_[21] - acc, 0); return true; } if (_[13] > 0) { let acc = _[13]; _[13] = max(_[13] - acc, 0); _[19] += acc * 1; _[22] += acc * 1; return true; } if (_[14] > 0) { let acc = _[14]; _[14] = max(_[14] - acc, 0); _[23] += acc * 1; return true; } if (_[15] > 0) { let acc = _[15]; _[15] = max(_[15] - acc, 0); _[10] += acc * 1; return true; } if (_[4] > 0 && _[5] > 0) { let acc = min(_[4],_[5]) _[4] = max(_[4] - acc, 0); _[5] = max(_[5] - acc, 0); _[3] += acc * 1; _[4] += acc * 1; return true; } if (_[4] > 0 && _[6] > 0) { let acc = min(_[4],_[6]) _[4] = max(_[4] - acc, 0); _[6] = max(_[6] - acc, 0); _[2] += acc * 1; return true; } if (_[7] > 0 && _[8] > 0) { let acc = min(_[7],_[8]) _[7] = max(_[7] - acc, 0); _[8] = max(_[8] - acc, 0); _[1] += acc * 1; _[7] += acc * 1; return true; } if (_[7] > 0 && _[9] > 0) { let acc = min(_[7],_[9]) _[7] = max(_[7] - acc, 0); _[9] = max(_[9] - acc, 0); _[0] += acc * 1; return true; } if (_[10] > 0) { let acc = _[10]; _[10] = max(_[10] - acc, 0); _[11] += acc * 1; _[12] += acc * 1; _[13] += acc * 1; _[14] += acc * 1; _[15] += acc * 1; return true; } if (_[11] > 0) { let acc = _[11]; _[11] = max(_[11] - acc, 0); _[16] += acc * 1; return true; } if (_[12] > 0) { let acc = _[12]; _[12] = max(_[12] - acc, 0); _[17] += acc * 1; _[18] += acc * 1; return true; } if (_[19] > 0) { let acc = _[19]; _[19] = max(_[19] - acc, 0); _[20] += acc * 1; return true; } if (_[13] > 0 && _[21] > 0) { let acc = min(_[13],_[21]) _[13] = max(_[13] - acc, 0); _[21] = max(_[21] - acc, 0); return true; } if (_[13] > 0) { let acc = _[13]; _[13] = max(_[13] - acc, 0); _[19] += acc * 1; _[22] += acc * 1; return true; } if (_[14] > 0) { let acc = _[14]; _[14] = max(_[14] - acc, 0); _[23] += acc * 1; return true; } if (_[15] > 0) { let acc = _[15]; _[15] = max(_[15] - acc, 0); _[10] += acc * 1; return true; } return false; } self.run = function() { let _ = self._; while(match(self, _)){}; }; self.log_state = function() { return Object.entries(self._).map(([k, v]) => `${k} :: ${v}`).join('\n'); }; return self; };