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
l=lambda\ | |
x0, y, x1, y1: \ | |
((dx := x1 - x0, dy := | |
y1-y,yi:=1,yi:=-1 if dy<0 else yi, | |
dy:=-dy if dy<0 else dy,d:=(2*dy)-dx,ps:= | |
set(),[(ps.add((x,y)),y:=y+yi,d:=d+2*(dy-dx))if d> | |
0 else(d:=d+2*dy)for x in range(x0,x1)]),ps)[1];pp=lambda \ | |
ps:list(map(print, [''.join(["-"if(x, y)in ps else" "for x in range | |
(127)])for y in range(10)]));pp(set.union(*[l(0, 0, i, 9) for i in range(37, 127)])) |
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 functools import reduce as red; from math import \ | |
(factorial as fact, comb);import sys;from decimal import \ | |
(getcontext as c,Decimal as dc);(a:=range, | |
b:=int(sys. argv[1]));c\ | |
().prec=b; ber=lambda\ | |
e,f=[dc(1)]: [f.append( | |
1-sum(comb(h ,g)*f[g]/(h | |
- g + 1) for g in a(h)))for | |
h in a(1, e + 1)] and abs( | |
f[-1]);print ((2 * fact(b) / |
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 functools import reduce | |
from math import factorial, comb | |
from decimal import getcontext, Decimal as Dec | |
from timeit import timeit | |
def bernoulli(n): | |
bs = [Dec(1)] | |
for m in range(1, n+1): | |
bs.append(1 - sum(comb(m, k)*b / (m - k + 1) for k, b in zip(range(m), bs))) |
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
n=256;q, t, m, e, p, c, f=(range(n),16,lambda x | |
,y, r=0:m((h:=x <<1,h^283)[ | |
h&n!= 0],y>> 1,(r,r ^x) | |
[y&1])if y else r,lambda | |
a,w= 1,p=n -2:e(m(a, a),(w,m | |
(w,a))[p&1] ,p>> 1)if p | |
else w, lambda b: list( | |
map (print,["%.2x "*t%(*b[r:r+t],)for | |
r in [*q][::t]])),lambda a,i: (a<<i|a>>8-i)&255 | |
,lambda a: (a^c(a,1)^c(a,2)^c(a,3)^c(a,4))^99); |
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 dataclasses import dataclass | |
from functools import reduce | |
@dataclass | |
class bff: | |
""" | |
An implementation of binary finite field arithmetic on fields of order 2^n using integers and bitwise operators. | |
Adaptation of algorithms in: |
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
/build/** | |
/venv*/** | |
/.idea/** | |
/repro.egg-info/** | |
/dist/ | |
**/*.so |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <pthread.h> | |
int sum; | |
struct input { | |
char* str; | |
int i; | |
}; | |
int NUM_THREADS; |
NewerOlder