Skip to content

Instantly share code, notes, and snippets.

@oguz-ismail
oguz-ismail / crtw32.c
Last active September 16, 2024 10:24
#include <windows.h>
#define DELIM(c) ((c) == ' ' || (c) == '\t')
static int
maybe_unescape(const TCHAR **src, TCHAR **dst, int quot) {
const TCHAR *p;
int i, n;
switch (*(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"
BEGIN {
FS = " |,"
}
{
if (/toggle/) {
x1 = $2; y1 = $3
x2 = $5; y2 = $6
}
else {
{
gsub(/./, "& ")
}
NR == 1 {
for (i = 1; i <= NF; i++)
light[bin(i-1)] = ($i == "#")
next
}
{
adapters[$0]
}
$0 > max {
max = $0
}
END {
adapters[0]
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX_NAME 7
#define NAME_FMT "%7[a-z] "
#define ALPHABET_SIZE 26
#define IS_ALPHA(c) ((c) >= 'a' && (c) <= 'z')
#define TO_INDEX(c) ((c)-'a')
#define NAME_SIZE (MAX_NAME+1)
{
gsub(/./, "& ")
for(i = 1; i <= NF; i++)
risk_level[i, NR] = $i
}
END {
find_lowest_total_risk()