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 traverse = (rows, colInc, rowInc = 1) => { | |
return rows.reduce((acc, row, index) => { | |
if (index % rowInc !== 0) { 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 parseRecord = (record) => { | |
const regex = /(\d+)\-(\d+) ([a-z]): ([a-z]*)/gi | |
return [...record.matchAll(regex)][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
// Part 1 | |
const input = `` | |
const findPairsForSum = (numbers, sum) => { | |
return numbers.reduce((acc, num1) => { | |
if (acc) { return acc } | |
const inner = numbers.find((num2) => num1 + num2 === sum) | |
if (inner) { return [num1, inner] } | |
}, null) | |
} |
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) => { |
NewerOlder