This file contains 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
import sys | |
from itertools import product | |
def first_pos(start, grid, m, n): | |
x, y = start | |
if x > 0 and grid[x-1][y] in ("|", "F", "7"): | |
return (x-1, y), "N" | |
if x < m-1 and grid[x+1][y] in ("|", "J", "L"): | |
return (x+1, y), "S" | |
if y > 0 and grid[x][y-1] in ("-", "F", "L"): |
This file contains 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
import sys | |
def first_pos(start, grid, m, n): | |
x, y = start | |
if x > 0 and grid[x-1][y] in ("|", "F", "7"): | |
return (x-1, y), "N" | |
if x < m-1 and grid[x+1][y] in ("|", "J", "L"): | |
return (x+1, y), "S" | |
if y > 0 and grid[x][y-1] in ("-", "F", "L"): | |
return (x, y-1), "W" |
This file contains 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
import sys | |
from itertools import islice | |
def parse_block(fh): | |
m = [] | |
while True: | |
try: | |
l = next(fh).rstrip() | |
except StopIteration: | |
break |
This file contains 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
import sys | |
from itertools import product | |
with open(sys.argv[1], "rt") as fh: | |
digits = {} | |
specials = set() | |
for i, line in enumerate(fh): | |
line = line.rstrip() | |
begin = None | |
l = "" |
This file contains 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 <cblas.h> | |
#include <omp.h> | |
#include <stdio.h> | |
#define DATASIZE 100 | |
double A[DATASIZE*DATASIZE]; | |
double B[DATASIZE*DATASIZE]; | |
double C[DATASIZE*DATASIZE]; |
This file contains 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
from itertools import product | |
fh = open("input16") | |
G = {} | |
Flow = {} | |
for line in fh: | |
line = line.rstrip() | |
first, second = line.split(";") | |
valve = first[6:8] | |
Flow[valve] = int(first.split("=")[1]) | |
l = second.split(", ") |
This file contains 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
import numpy as np | |
import re | |
fh = open("input22") | |
cubes = [] | |
X, Y, Z = set(), set(), set() | |
for i, line in enumerate(fh): | |
line = line.strip() | |
m = re.match("(on|off) x=([^.]*)..([^,]*),y=([^.]*)..([^,]*),z=([^.]*)..(.*)", line) | |
action, *coords = m.groups() |
This file contains 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
from collections import Counter | |
d = sum((Counter({w:int(n)}) for w, n in map(str.split, open("input"))), Counter()) | |
print(d["forward"] * (d["down"] - d["up"])) |
This file contains 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
diff --git a/PKGBUILD b/PKGBUILD | |
index f7038ee..7158d63 100644 | |
--- a/PKGBUILD | |
+++ b/PKGBUILD | |
@@ -1,15 +1,15 @@ | |
pkgname=python-cu2qu | |
_module=cu2qu | |
-pkgver=1.6.4 | |
+pkgver=1.6.5 | |
pkgrel=1 |
This file contains 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
def tree(p): | |
n = len(p) + 1 | |
g = [0.] * (n-1) | |
h = [0.] * (n-1) | |
i = n - 2 | |
while i >= 0: | |
l = 2 * i + 1 | |
r = 2 * i + 2 | |
if l >= n - 1: | |
g[i] = p[l - n] |
NewerOlder