Skip to content

Instantly share code, notes, and snippets.

@kevincharm
kevincharm / fizzbuzz.js
Last active November 29, 2017 03:57
The Fizziest of Buzzes. Note: this is a joke.
const magic = 0x46697a7a
const witchcraft = magic ^ (0x41c << 16)
const u = x => a => b => (x >> a) + (x & b)
const v = x => a => b => x > a ? x - b : x
const w = x => u(u(u(x)(16)(0xffff))(8)(0xff))(4)(0xf)
const rin = x => s => !!parseInt(x) ? s : x + s
const c = x => a => b => String.fromCharCode((x >> a) & b)
const cccc = x => c(x)(24)(0xff)+c(x)(16)(0xff)+c(x)(8)(0xff)+c(x)(0)(0xff)
const fizz = x => !(v(u(u(u(w(x))(2)(3))(2)(3))(2)(3))(2)(3))
const buzz = x => !(v(v(v(w(x))(14)(15))(4)(5))(4)(5))
// -*- node.jz -*-
let input = ''
process.stdin.on('readable', () => input += process.stdin.read() || '')
process.stdin.on('end', () => main())
function ecmascriptify(input) {
const regs = {}
const weEczemaSkriptNow = input
.split('\n')
@kevincharm
kevincharm / day9-no-eval.js
Last active December 9, 2017 07:27
aoc2017
// -*- node.jz -*-
let input = ''
process.stdin.on('readable', () => input += process.stdin.read() || '')
process.stdin.on('end', () => main())
const evil = eval
class DepthCounter {
constructor() {
this.depth = 0
@kevincharm
kevincharm / day10.js
Created December 10, 2017 11:35
long
// -*- node.jz -*-
let input = ''
process.stdin.on('readable', () => input += process.stdin.read() || '')
process.stdin.on('end', () => {
const args = process.argv.slice(2)
const rounds = args[0]
main(rounds)
})
// -*- node.jz -*-
let input = ''
process.stdin.on('readable', () => input += process.stdin.read() || '')
process.stdin.on('end', () => {
main()
})
const dist = (i, j) => Math.abs(i) + Math.abs(j)
// -*- node.jz -*-
let input = ''
process.stdin.on('readable', () => input += process.stdin.read() || '')
process.stdin.on('end', () => {
main()
})
function dedupeConcat(p, c) {
const deduped = c.filter(item => !p.includes(item))
// -*- node.jz -*-
let input = ''
process.stdin.on('readable', () => input += process.stdin.read() || '')
process.stdin.on('end', () => {
main()
})
const scanner = (depth, range, t = 0) => {
range -= 1
@kevincharm
kevincharm / day14.js
Created December 14, 2017 16:38
bloody long
// -*- node.jz -*-
let input = ''
process.stdin.on('readable', () => input += process.stdin.read() || '')
process.stdin.on('end', () => main())
function leftpad(str, char = 0, len = 2) {
let res = str.slice()
if (str.length < len) {
const pad = len - str.length
@kevincharm
kevincharm / day15.c
Created December 15, 2017 13:39
aoc17
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
int64_t judge_one(int64_t a, int64_t b) {
const int pairs = 40000000;
int64_t total = 0;
for (int i=0; i<pairs; i++) {
a = (a * 16807) % INT32_MAX;
b = (b * 48271) % INT32_MAX;
// -*- node.jz -*-
let input = ''
process.stdin.on('readable', () => input += process.stdin.read() || '')
process.stdin.on('end', () => main())
const spin = (programs, size) => {
while (size--) programs.unshift(programs.pop())
}