v1
- by slutske22 1/14/202200
Setup HTML - click to add setup HTML
Setup JS - click to add setup JavaScript
delete caserun single casemove downdrag and drop case


ready



class Cell {
	constructor(x, y) {
		this.count = 0;
		this.x = x;
		this.y = y;
	}

	get neighbors() {
		if (this._neighbors) return this._neighbors;

		this.count++;

		const { x, y } = this;

		let neighbors = [];
		for (let j = -1; j <= 1; j++) {
			for (let i = -1; i <= 1; i++) {
				if (!(i === 0 && j === 0)) {
					neighbors.push(new Cell(x + i, y + j));
				}
			}
		}
		this._neighbors = neighbors;
		return this._neighbors;
	}
}

const cells = Array.from({ length: 100 }).map((_, i) => new Cell(5, 5));

cells.forEach((cell) => {
	for (i = 0; i < 100; i++) {
		const n = cell.neighbors;
	}
});

delete caserun single casemove updrag and drop case


ready



class Cell {
	constructor(x, y, makeNeighbors = true) {
		this.count = 0;
		this.x = x;
		this.y = y;

		if (makeNeighbors) {
			this.neighbors = this.getNeighbors();
		}
	}

	getNeighbors() {
		this.count++;

		const { x, y } = this;

		let neighbors = [];
		for (let j = -1; j <= 1; j++) {
			for (let i = -1; i <= 1; i++) {
				if (!(i === 0 && j === 0)) {
					neighbors.push(new Cell(x + i, y + j, false));
				}
			}
		}
		return neighbors;
	}
}

const cells = Array.from({ length: 100 }).map((_, i) => new Cell(5, 5));

cells.forEach((cell) => {
	for (i = 0; i < 100; i++) {
		const n = cell.neighbors;
	}
});
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN