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] |
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 <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) |
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(i = 1; i <= NF; i++) | |
risk_level[i, NR] = $i | |
} | |
END { | |
find_lowest_total_risk() |
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
{ | |
pos[NR] = $NF | |
} | |
END { | |
count_wins(pos[1], pos[2]) | |
if (wins[1] > wins[2]) | |
print wins[1] | |
else | |
print wins[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
bc <<EOF | |
$(awk -F, ' | |
NR == 1 { | |
print "t = " $0 | |
next | |
} | |
{ | |
j = 0 | |
for (i = 1; i <= NF; 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
{ | |
gsub(/,/, "") | |
incr[$NF] = $(NF-1) | |
for (i = 1; i < NF-2; i += 2) { | |
reqs[$NF, ++nreqs[$NF]] = $(i+1) | |
qtys[$NF, $(i+1)] = $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
#include <assert.h> | |
#include <limits.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define MAX_WIDTH 100 | |
#define MAX_HEIGHT 100 | |
#define QUEUE_CAP 4096 | |
struct position { |
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 <assert.h> | |
#include <math.h> | |
#include <signal.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <time.h> | |
#include <unistd.h> | |
#ifdef __WIN32 |