Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const key = (i, j) => {
- return `${i},${j}`;
- };
- const parse = (input) => {
- const grid = utils.getInputLines(input).map((e) => e.trim().split(""));
- const walls = {};
- const plots = {};
- let start = { i: 0, j: 0 };
- for (let i = 0; i < grid.length; i++) {
- for (let j = 0; j < grid[i].length; j++) {
- const value = grid[i][j];
- if (value == "#") {
- walls[key(i, j)] = true;
- }
- if (value == "S") {
- plots[key(i, j)] = -1;
- start = { i: i, j: j };
- }
- }
- }
- return {
- walls: walls,
- plots: plots,
- start: start,
- size: grid.length,
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement