Skip to content

Instantly share code, notes, and snippets.

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) {
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 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) {
//------------------------------------------------
// 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)
//=============================================
// 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)
// 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.
import fs = require("fs")
import color = require("cli-color")
enum IPNumberType {
Regular,
Hypernet
}
interface IPNumber {
type: IPNumberType,
@pseale
pseale / day6.js
Last active December 13, 2016 01:17
//----------------------------------------------------
// 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)
/* 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
@pseale
pseale / day3.js
Last active December 12, 2016 06:16
/* 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
*/