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
import _ = require("lodash") | |
let partAInput = "01110110101001000" | |
function flipItAndReverseIt(input: string): string { | |
return input.concat("0").concat((_.reverse(input.split(""))).map(x => x === "1" ? "0" : "1").join("")) | |
} | |
function fillDisk(input: string, size: number): string { | |
let data = input | |
while (data.length < size) { |
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
import _ = require("lodash") | |
let input = `Disc #1 has 13 positions; at time=0, it is at position 11. | |
Disc #2 has 5 positions; at time=0, it is at position 0. | |
Disc #3 has 17 positions; at time=0, it is at position 11. | |
Disc #4 has 3 positions; at time=0, it is at position 0. | |
Disc #5 has 7 positions; at time=0, it is at position 2. | |
Disc #6 has 19 positions; at time=0, it is at position 17.` | |
interface Disc { |
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
import crypto = require("crypto") | |
import _ = require("lodash") | |
let seed = "ahsbgdzn" | |
let useKeyStretching = true // part A / part B differentiator | |
let hashes: Object = {} | |
function getHash(i: number) { | |
if (hashes[i] === undefined) { | |
if (useKeyStretching) { |
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
//------------------------------------------------ | |
// Node console runner | |
import fs = require("fs") | |
import Global = require("./global") | |
import parse = require("./parse") | |
import run = require("./run") | |
const input = fs.readFileSync("./input.txt", "utf8") | |
const instructions = parse(input) |
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
//============================================= | |
// Main - Node console runner | |
import fs = require("fs") | |
import Factory = require("./factory") | |
import parse = require("./parse") | |
const input = fs.readFileSync("./input.txt", "utf8") | |
const events = parse(input) |
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
// DISCLAIMER: | |
// | |
// I'm getting lazier as I power through more and more of these Advent of Code challenges. | |
// Notably, I couldn't muster the energy to: | |
// * fix naming (e.g. part A is named "parseA" and part B is named "count") | |
// * Write part B tests | |
// * Write fine-grained unit tests | |
// * I probably left dead code in here | |
// | |
// Just know that I'm probably ashamed of some of this, but my laziness exceeds my fear of shame. |
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
import fs = require("fs") | |
import color = require("cli-color") | |
enum IPNumberType { | |
Regular, | |
Hypernet | |
} | |
interface IPNumber { | |
type: IPNumberType, |
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
//---------------------------------------------------- | |
// main script | |
import fs = require("fs") | |
import _ = require("lodash") | |
import parse = require("./parse") | |
import decode = require("./decode") | |
const input = fs.readFileSync("./input.txt", "utf8") | |
const columns = parse(input) | |
const decoded = decode(columns) |
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
/* test results: | |
PASS __tests__\day4.test.js | |
Acceptance tests | |
√ aaaaa-bbb-z-y-x-123[abxyz] is a real room (15ms) | |
√ totally-real-room-200[decoy] is not a real room | |
parsing | |
√ aaaaa-bbb-z-y-x-123[abxyz] | |
generating a checksum | |
√ aaaaa-bbb-z-y-x-123[abxyz] | |
decrypt |
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
/* test results: | |
PASS __test__\day3.test.js | |
Acceptance tests | |
√ 5 10 25 | |
√ 5 10 25, but not in any order of size | |
√ valid triangle 5 5 5 | |
Vertical parsing | |
√ Input with wrong number of rows will throw an error (15ms) | |
√ Vertical triangles are parsed in groups of 3 | |
*/ |
NewerOlder