Skip to content

Instantly share code, notes, and snippets.

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"):
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"
import sys
from itertools import islice
def parse_block(fh):
m = []
while True:
try:
l = next(fh).rstrip()
except StopIteration:
break
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 = ""
@thrasibule
thrasibule / test_lock.c
Created July 20, 2023 20:12
blas test for bug #4017
#include <cblas.h>
#include <omp.h>
#include <stdio.h>
#define DATASIZE 100
double A[DATASIZE*DATASIZE];
double B[DATASIZE*DATASIZE];
double C[DATASIZE*DATASIZE];
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(", ")
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()
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"]))
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
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]