Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <string.h>
#define HASH(h, c) do { \
h *= 5; \
switch (c) { \
case 'w': h++; case 'b': h++; \
case 'u': h++; case 'r': h++; \
case 'g': h++; \
} \
.globl _start
.section .rodata
0: .asciz "/dev/null"
.bss
.skip 23
1: .skip 1
.text
# Usage: jq -s -f aoc22-13.jq input.txt
def cmp_list($l; $r):
def cmp_elem($l; $r):
($l | type) as $lt
| ($r | type) as $rt
| if $lt == $rt then
if $lt == "null" then
0
elif $lt == "number" then
cc -nostdlib hello.c syscall.S -static -no-pie -lc
#include <stdio.h>
#define N 0x2000
typedef struct {
long long k, v;
} tbl[N];
static long long *
cell(tbl t, long long k) {
unsigned i;
#include <windows.h>
#define DELIM(c) ((c) == ' ' || (c) == '\t')
static int
maybe_unescape(const TCHAR **src, volatile TCHAR **dst, int quot) {
const TCHAR *p;
int i, n;
p = *src;
od -A n -v -t u1 | awk '
BEGIN {
conv[0] = "/*%s*/ %s/4 /*%s*/"
conv[1] = "16*(%s%%4) + %s/16 /*%s*/"
conv[2] = "4*(%s%%16) + %s/64\n%s%%64"
tail[0] = "16*(%s%%4)\n64\n64"
tail[1] = "4*(%s%%16)\n64"
tail[2] = "/*%s*/"
state = 2
}
{
gsub(/./, "& ")
for (x = 1; x <= NF; x++)
heat_loss[x, NR] = $x
}
END {
find_least_heat_loss(1, 3)
find_least_heat_loss(4, 10)
}
BEGIN {
FS = "=|; |, | "
}
{
flow_rate[$2] = $6
for (i = 11; i <= NF; i++)
tunnels[$2, ++ntunnels[$2]] = $i
}
BEGIN {
products[elements[1] = "111312211312113221133211322112211213322113"] \
= "31131122211311122113222 12 312211322212221121123222113"
# {{{
products[elements[2] = "111312211312113221133211322112211213322112"] \
= "31131122211311122113222 12 312211322212221121123222112"
products[elements[3] = "1321132122211322212221121123222113"] \
= "111312211312113221133211322112211213322113"
products[elements[4] = "1321132122211322212221121123222112"] \
= "111312211312113221133211322112211213322112"