From 8c17222a7edf55896773335eea18c6f89e0ca923 Mon Sep 17 00:00:00 2001 From: elioat Date: Fri, 7 Jun 2024 19:11:41 -0400 Subject: * --- ts/bun/index.ts | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'ts') diff --git a/ts/bun/index.ts b/ts/bun/index.ts index bcde236..0a0f217 100644 --- a/ts/bun/index.ts +++ b/ts/bun/index.ts @@ -1,4 +1,4 @@ -type Grid = boolean[][]; +type Grid = number[][]; export function printGrid(grid: Grid): void { grid.forEach(row => console.log(row.map(cell => cell ? '1' : '0').join(' '))); @@ -40,34 +40,33 @@ export function simulate(initial: Grid, steps: number): void { } const initial: Grid = [ - [false, true, false], - [false, true, false], - [false, true, false] + [0, 1, 0], + [0, 1, 0], + [0, 1, 0] ]; const flyer: Grid = [ - [false, false, false, false, false, false], - [false, false, false, false, false, false], - [false, false, false, false, false, false], - [false, false, false, true, false, false], - [false, false, false, false, true, false], - [false, false, true, true, true, false], - [false, false, false, false, false, false], - [false, false, false, false, false, false], - [false, false, false, false, false, false] + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 1, 0, 0], + [0, 0, 0, 0, 1, 0], + [0, 0, 1, 1, 1, 0], + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0] ]; const toad: Grid = [ - [false, false, false, false, false, false], - [false, false, false, false, false, false], - [false, false, false, true, false, false], - [false, true, false, false, true, false], - [false, true, false, false, true, false], - [false, false, true, false, false, false], - [false, false, false, false, false, false] + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 1, 0, 0], + [0, 1, 0, 0, 1, 0], + [0, 1, 0, 0, 1, 0], + [0, 0, 1, 0, 0, 0], + [0, 0, 0, 0, 0, 0] ]; - simulate(initial, 5); simulate(flyer, 5); -simulate(toad, 5); \ No newline at end of file +simulate(toad, 5); -- cgit 1.4.1-2-gfad0