This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puzzleInput = `` | |
const parseInput = (input) => { | |
return input.split(/\n/) | |
} | |
// Part 1 | |
const nextDir = (facing, going, amount) => { | |
const clockwise = 'NESW' | |
const facingIndex = clockwise.indexOf(facing) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puzzleInput = `` | |
// Common | |
const parseInput = (input) => { | |
return input.split(/\n/).map(x => x.split('')) | |
} | |
const considerSurroundings = (rows, rowIndex, colIndex, comparator, maxDistance, threshold) => { | |
const range = [-1, 0, 1] | |
return range.reduce((acc1, yOffset) => ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puzzleInput = `` | |
// Part 1 | |
const parseInput = (input) => { | |
return input.split(/\n/).map(x => parseInt(x)) | |
} | |
const getDifferences = (adapters) => { | |
return adapters.map((adapter, index) => { | |
let prev = adapters[index - 1] || 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puzzleInput = `` | |
// Part 1 | |
const parseInput = (input) => { | |
return input.split(/\n/).map(x => parseInt(x)) | |
} | |
const findInvalidNumber = (numbers) => { | |
return numbers.reduce((acc, number, index) => { | |
if (index < 25) { return acc } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puzzleInput = `` | |
// Part 1 | |
const parseInput = (input) => { | |
return input.split(/\n/) | |
} | |
const interpretInstruction = (line) => { | |
let [command, amount] = line.split(' ') | |
return { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puzzleInput = `` | |
// Part 1 | |
const parseInput = (input) => { | |
return input.split(/\n/) | |
} | |
const interpretRule = (rule) => { | |
const matches = [...rule.matchAll(/^([a-z ]+) bags contain ((\d+ [a-z ]+(, )?)+|no other bags)\.$/gi)][0] | |
const contain = matches[2].split(', ').map(str => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pro tip: watch for google trying to auto-translate the puzzle input lol | |
const puzzleInput = `` | |
// Part 1 | |
const parseInput = (input) => { | |
return input.split(/\s\s/) | |
} | |
const groupCountAny = (group) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puzzleInput = `` | |
// Part 1 | |
const TOTAL_ROWS = 128 | |
const TOTAL_COLS = 8 | |
const parseInput = (input) => { | |
return input.split('\n') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puzzleInput = `` | |
// Part 1 | |
const parseInput = (input) => { | |
return input.replace(/\s/gi, '\n').split('\n\n') | |
} | |
const validateSurfaceFields = passport => { | |
const fields = passport.split('\n').map(field => field.substr(0, 3)) | |
return fields.length === 8 || (fields.length === 7 && !fields.includes('cid')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puzzleInput = `` | |
// Part 1 | |
const parseInput = (input) => { | |
return input.split('\n') | |
} | |
const traverse = (rows, colInc, rowInc = 1) => { | |
return rows.reduce((acc, row, index) => { | |
if (index % rowInc !== 0) { return acc } |
NewerOlder