I like finite fields, and calculating mathematical constants. My main interests are in number theory and statistics. Look at my quines!
My github is: github.com/juliusgeo
Hello! Welcome to my website. Check out my quines!.
Calculates pi
to 2 digits of precision by calculating the area of the comments. Based on the 1988 IOCCC solution.
print(''.join(b:=open(__file__).readlines()[1:]).count("#")/len(b)/4) ####### ################# #######--------######## ######-------------####### ######-----------------###### #####------------------###### ######-------------------###### #####--------------------###### #####---------!\---------###### ######--------!$#\-------###### ######-------!#$#$#\---###### ######-------!#$#$##$#\##### #######-----!$#$#$#$#$#\### ##########!$#$#$#$#$##\ ######!$#$#$### ##!####
Uses Bresenham's line drawing algorithm to trace out the shape of the source code.
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)]))
Calculates pi
to many digits of precision by using Bernoulli numbers and the derivation found in Plouffe (2022)
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) / (ber(b)* 2** b * red(dc.__mul__ , [1 - (1/dc (i) ** b) for i in [2, 3, 5, 7] ]))) ** (1 / dc(b))) #juliusgeo pi arb. precis.
Calculate the Rijdnael S-box (and inverse) using finite field arithmetic. It also takes up less than 512 bytes, which would be the number needed for a simple lookup table.
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 <>8-i)&255,lambda a:(a^c(a,1)^c(a,2) ^c(a,3)^c(a,4))^99);p(s:=[f(e(i))for i in q]),p([*map(s.index,q)])