Skip to content

Instantly share code, notes, and snippets.

import fs = require("fs")
import color = require("cli-color")
enum IPNumberType {
Regular,
Hypernet
}
interface IPNumber {
type: IPNumberType,
// 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.
//=============================================
// 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)
//------------------------------------------------
// 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)
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) {
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 {
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) {