diff --git a/2023/16/impl.js b/2023/16/impl.js index 53605f9..899f091 100644 --- a/2023/16/impl.js +++ b/2023/16/impl.js @@ -15,8 +15,8 @@ const mirrors = { "\\": { "U": "L", "D": "R", - "R": "U", - "L": "D" + "R": "D", + "L": "U" } } @@ -31,16 +31,17 @@ const solve = (input) => { return const curr = tiles[pos[0]][pos[1]] - console.log(`trav ${pos} curr ${curr} direction ${direction}`) energized.push([pos[0], pos[1], direction]) if(curr === '/' || curr === '\\') { direction = mirrors[curr][direction] } else if(curr === '|' && (direction === "L" || direction === "R")) { traverse([pos[0] + directions["U"][0], pos[1] + directions["U"][1]], "U") traverse([pos[0] + directions["D"][0], pos[1] + directions["D"][1]], "D") + return } else if(curr === '-' && (direction === "U" || direction === "D")) { traverse([pos[0] + directions["L"][0], pos[1] + directions["L"][1]], "L") traverse([pos[0] + directions["R"][0], pos[1] + directions["R"][1]], "R") + return } traverse([pos[0] + directions[direction][0], pos[1] + directions[direction][1]], direction) }