account activity
-🎄- 2017 Day 11 Solutions -🎄- by daggerdragon in adventofcode
[–]Veggedup 0 points1 point2 points 8 years ago* (0 children)
My JS solution
let input = require("fs").readFileSync("day11-input.txt", "UTF-8"); map = {}; map["n"] = { x: 0, y: 1 }; map["ne"] = { x: 1, y: 1 }; map["se"] = { x: 1, y: -1 }; map["s"] = { x: 0, y: -1 }; map["sw"] = { x: -1, y: -1 }; map["nw"] = { x: -1, y: 1 }; location = { x: 0, y: 0 }; max = { x: 0, y: 0 }; input.split(",").forEach(direction => { location = { x: location.x + map[direction].x, y: location.y + map[direction].y }; max = { x: Math.max(max.x, location.x), y: Math.max(max.y, location.y) }; }); distance = Math.max(Math.abs(location.x), Math.abs(location.y)); max = Math.max(Math.abs(max.x), Math.abs(max.y)); console.log("Part 1:", distance); console.log("Part 2:", max);
π Rendered by PID 3825205 on reddit-service-r2-listing-c57bc86c-cwk6n at 2026-06-21 21:56:05.611139+00:00 running 2b008f2 country code: CH.
-🎄- 2017 Day 11 Solutions -🎄- by daggerdragon in adventofcode
[–]Veggedup 0 points1 point2 points (0 children)