This file contains hidden or 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
# 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 |
This file contains hidden or 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
cc -nostdlib hello.c syscall.S -static -no-pie -lc |
This file contains hidden or 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
#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; |
This file contains hidden or 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
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 | |
} |
This file contains hidden or 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
{ | |
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) | |
} |
This file contains hidden or 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
BEGIN { | |
FS = "=|; |, | " | |
} | |
{ | |
flow_rate[$2] = $6 | |
for (i = 11; i <= NF; i++) | |
tunnels[$2, ++ntunnels[$2]] = $i | |
} |
This file contains hidden or 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
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" |
This file contains hidden or 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
BEGIN { | |
FS = " |," | |
} | |
{ | |
if (/toggle/) { | |
x1 = $2; y1 = $3 | |
x2 = $5; y2 = $6 | |
} | |
else { |
This file contains hidden or 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
{ | |
gsub(/./, "& ") | |
} | |
NR == 1 { | |
for (i = 1; i <= NF; i++) | |
light[bin(i-1)] = ($i == "#") | |
next | |
} |
This file contains hidden or 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
{ | |
adapters[$0] | |
} | |
$0 > max { | |
max = $0 | |
} | |
END { | |
adapters[0] |
NewerOlder