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
#!/usr/bin/env python3 | |
# -*- coding: utf8 -*- | |
import numpy as np | |
f = open('16.in').read().strip() | |
l = np.array([int(s) for s in f], dtype=int) | |
def get_matrix(llen): |
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
#!/usr/bin/env python3 | |
# -*- coding: utf8 -*- | |
from aocd import data | |
from re import compile | |
import math | |
x = compile('(.*) => (\d+) (\S+)') | |
y = compile('(\d+) (\S+)') |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdbool.h> | |
#include "intcode.h" | |
#define WIDTH 50 | |
#define HEIGHT 30 | |
#define MAX_NUM_OUTPUTS 5000 |
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
#!/usr/bin/env python3 | |
# -*- coding: utf8 -*- | |
import numpy as np | |
from re import compile | |
from math import gcd | |
def minsta_gemensamma(a, b): | |
return abs(a*b) // gcd(a, b) |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdbool.h> | |
#include "intcode.h" | |
#define WIDTH 120 | |
#define HEIGHT 120 | |
#define WHITE (1) | |
#define BLACK (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
#!/usr/bin/env python3 | |
# -*- coding: utf8 -*- | |
import numpy as np | |
from math import gcd, atan2 | |
data = open("10.in","r").read().split("\n")[:48] | |
def angles_and_distances_as_seen_from(from_r, from_c, m): | |
r,c = m.shape | |
ang_dist = [] |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdbool.h> | |
#define IMMEDIATE (1) | |
#define POSITIONAL (0) | |
#define RELATIVE (2) | |
#define ARG0_ADDR (p[i+1] + ((modes[0] == RELATIVE) ? relative_base : 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
#!/usr/bin/env python3 | |
# -*- coding: utf8 -*- | |
import numpy as np | |
m = np.fromfile('8.in', dtype=np.uint8, count=25*6*100).reshape((100,6,25)) - 48 | |
f = m.reshape((m.shape[0], m.shape[1]*m.shape[2])) | |
best_layer = np.argmin(f.shape[1] - np.count_nonzero(f, axis=1)) | |
print("Pt 1:", (f.shape[1] - np.count_nonzero(f[best_layer,:]-1)) * (f.shape[1] - np.count_nonzero(f[best_layer,:]-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
#!/usr/bin/env python3 | |
# -*- coding: utf8 -*- | |
from re import compile | |
x = compile(r"(\S+)\)(\S+)") | |
orbits = [x.match(r).groups() for r in open('6.in','r').read().split('\n') if x.match(r) is not None] | |
def orbit_checker(all_orbits, center, depth): | |
s = [orbit_checker(all_orbits, j[1], depth+1) for j in [x for x in orbits if x[0] == center]] |
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
// Input: 1 - pt 1, 2 - pt 2 | |
3,PROGRAM_MODE | |
1001,PROGRAM_MODE,-1,PROGRAM_MODE | |
1101,DATA_START,-1,DATA_INDEX | |
1101,0,0,TOTAL_MASS | |
// Get next mass value | |
NEXT_MASS: | |
1001,DATA_INDEX,1,DATA_INDEX | |
// Check if data is -1 |