Skip to content

Instantly share code, notes, and snippets.

{
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()
{
pos[NR] = $NF
}
END {
count_wins(pos[1], pos[2])
if (wins[1] > wins[2])
print wins[1]
else
print wins[2]
bc <<EOF
$(awk -F, '
NR == 1 {
print "t = " $0
next
}
{
j = 0
for (i = 1; i <= NF; i++) {