One of the coolest things I've hacked together as a sort of side project the last few weeks is a property-based test for POSIX filesystems, which uses a simple in-memory model of mv, cat, etc to verify the safety of a real filesystem:

github.com/jepsen-io/jepsen/bl

And here's an example bug it found in lazyfs--the original 1,998 ops it took to find, and the shrunk 5-op minimal reproducing case:

gist.github.com/aphyr/de84b509

Look at this lovely blog post from Michelin. “[Java interop] was a huge advantage, as it helped to integrate seamlessly Clojure with our standard development stack: Java/SpringBoot.”

Now I’m only curious whether it was their tyre or restaurant guide division.

blogit.michelin.io/clojure-pro

If you are fleeing the war in Ukraine and coming to the EU, you can find information on our webpage about:

🚆Travel
🚸Children protection
🎓 Education
🩺Healthcare
💼Jobs
🏠Housing
🔒Safety

🔗EU Stands with Ukraine. ➞ europa.eu/!VJY6fg

Advent of Code in K, day 18 

/ ...continued:
unpack: {x[1_|1_|!]}
xpl: {:[:anyxpl x; unpack doxpl[(,w#b),x,,w#b;1+*i]; x]}
half: {(x,1+x)%2}
splmid: {-1!'b+i*/:(-b)+half@*x@&i:9<x}
dospl: {(y#x),splmid[x[y]],(y+1)_ x}
spl: {:[:&|/'9<x; dospl[x;*i]; x]}
red: {:[x~t:xpl x; :[x~t:spl x; x; t]; t]}
add: {red/-1!'x,y}
one: *(w-1) mag/(add/nums)[;w-2]
ids: i@&~=/'i:,/i,\:/:i:!
sums: {add/nums[x]}'ids
two: (|/,/{(w-1) mag/x}'sums[;;w-2])
/
/ janstepien.com/2021/aoc/

Show thread

Advent of Code in K, day 18 ½ 

f: "18.txt"
pair: {m:x 1_ y; l:x (2+m[1]) _ y; (,m[0],*l;3+m[1]+l[1])}
parse: {:["["=*x; pair[_f;x]; (0$1#x;1)]}
b: -1
w: 5
arr: {:[@ z; (x#b),z,((y-x)#b); ,/_f[x+1;y]'z]}[-2;w-1]
read: {(()%w;w)#ns:arr@*parse x}
mag: {(+/'((()%2),2)#x*()#3 2)}
nums: read'0:f
zero: {?b*~1!'b<x}
anyxpl: {(|:'(,':i)@&1=-':i:-2,&b<d:x[;w-1])}
xplmid: {(,t[0]),zero[a],,*1!t:z+(b<z) * +/'a*b<a:x[y]}
doxpl: {m:x@(-1 1)+y; ((-1+*y)#x),xplmid[x;y;m],(2+y[1])_ x}
/ ...

Advent of Code in K, day 17 

f: "17.txt"
s: {y@{1+y+!x-(1+y)}':-1,&x=y,x}
in: {(0$')'(s["."]'*:'s[","]' 1_ s["="]@*0:x)[;0 2]}[f]
miss: {(x[1;0]>y[1])|x[0;1]<y[0]}
hit: {(~x[1;1]<y[1])&(~x[1;0]>y[1])&(~x[0;0]>y[0])&(~x[0;1]<y[0])}
step: {(y+x;(0|-1+*y),-1+y[1])}
sim: {:[hit[x;y]; (y;1); miss[x;y]; (y;0); step[y;z]]}
simv: {{sim[in]/x}\(0 0;x)}
dom: ,/t,\:/:-150+t:!350
peak: {:[*|*|x; |/x[;0;1]; -1]}
hits: {(*|*|x)}
sims: sims@&hits'sims:simv'dom
one: |/ |/' sims[;;0;1]
two:
/

Advent of Code in K, day 16 

/ ...continuing from above:
op: {(op0;op1)[*y][x] 1_ y}
dec: {(num[3#x],id,p[1];(6+*p::[4=id:num[3#3_ x]; lit; op[dec]] 6_ x) _ x)}
versions: {x[0],:[@*2!x; !0; _f'2_ x]}
ops: (+;*;&;|;0;>;<;~)
walk: {:[4=x[1]; x[2]; ops[x[1]]/_f'2_ x]}
input: *dec bits@*0:file
one: +/,//versions input
two: walk input
/ This one had no chance of fitting into a sigle toot.
/

Show thread

Advent of Code in K, day 16 ½ 

file: "16.txt"
bin: {((4-)#0),n:{:[x<2; x; _f[x%2],x!2]} x}
bits: {:,/bin'{ d-7*9<d:(_ic x)-48 } x}
num: {(+/(|(-1+)(2*)\1)*x)}
litrec: {:[*x; (,4#1_ x),_f[5_ x]; ,4#1_ x]}
lit: {((5*)%4),num r:,/litrec x}
seqdec: { (,*d) , :[#*1!d:x y; _f[x; d[1]]; !0]}
ndec: { d: y z; (,(()-[1]),*d),:[x=1; !0; _f[x-1;y;d[1]]]}
op0: {l: num 15#y; (15 + l + 1; seqdec[x] l # 15 _ y)}
op1: {r: ndec[n:num 11#y;x] 11 _ y; (+/1,11,*:'r; 1_'r)}
/ , continued below

Advent of Code in K, day 15 

inp: (0$')'0:"15.txt"
grow: {1+x!9}
full: ,/ 4 grow\ ,/' + 4 grow\inp
at: {(y[0]),(,(y[1][*y]),z,(1+y[1])_ x[*y]),(1+*y)_ x}
init: {at[{:+/t*t:y-x}[0 0;t,t:-1+] + x - x;0 0;0]}
ns: {n@&(()>|/'n)&~0>&/'n:y+/:t,-t:(>:)\0 1}
step: {
i:(_abs y'n)>v:(_abs y c) + x'n:n@&0<y' n:ns[y] c:*z
d:{at[x;1_ y;*y]}/(,y),(v,'n)@&i
(at[d;c;-y c];{y@<x'y:?y}[d;(1_ z),n])}
go: {_abs *|*|*{-1+x*x}[]{step[x]/y}[x]/(init[x];,0 0)}
one: go inp
two: go full
/

Advent of Code in K, a variant of APL, day 14 

lines: 0:"14.txt"
split: {y@{1+y+!x-(1+y)}':-1,&x=y,x}
rule: {(`$*x;`$'(x[0;0],x[1];x[1],x[0;1]))}
rules: + rule' (split[" "]'2_ lines)[;0 2]
pairs: * rules
init: +/ pairs=/: `$' {(-1+)#x} {+(,x),,1!x}@*lines
produce: {x[1;*&y=*x]} rules
iter: {:+/{y*+/pairs=/:x}'[produce'pairs[&0<x]; x@&x>0]}
keys: (*|*lines),($pairs)[;0]
solve: {f:+/'(1,x iter/init)@=keys; -/(f@>f)[-1+1,]}
one: solve 10
two: solve 40
/
/ janstepien.com/2021/aoc/

Advent of Code in K, day 13 

lines:0:"13.txt"
s:{y@{1+y+!x-(1+y)}':-1,&x=y,x}
folds:{x:s["="]x;("x"=*|*x;0$*1!x)}'lines@&"f"=*:'lines
dots:{0$' s[","]x}'((-)+-1+)#lines
m1: {(x,2)#1 -1}
xfold:{x@&s:x[;1]>y;
d:((+/s),2)#0,2*y;
x[&~s],m1[+/s]*x[&s]-d}
fold:{:[*y; 1!'xfold[1!'x]y 1; xfold[x]y 1]}
one: #?fold[dots]folds 0
done: {fold[x]y}/((,dots),folds)
w:|/done[;0]
h:|/done[;1]
row: {(|/(!1+w)=/:x[&y=x[;1];0])}[done]
two: row'!1+h
/
/ janstepien.com/2021/aoc/

Advent of Code in K, day 12 

f: "12.txt"
all: p,1!'p:(`$')'{y@{1+y+!x-(1+y)}':-1,&x=y,x}["-"]'0:f
edges: all@&(~`start=all[;1])&~`end=all[;0]
big: {*(_ic"a")>_ic$x}
grow: {(edges[&(*x)=edges[;0];1]),\:x}
next: {done: d@&{(|/x=*y)}[y]'d:z 1
more: {g@&x'g:grow y} x
(;done,(,/more'((*z) _ z 1)))}
compl: {{(|/x=*y)}[x]'y}
fix: {:[y~b:x y;b;_f[x;b]]}
solve: {+/ (compl x) fix[(next y) x;(0;,,`start)][1]}@,`end
one: solve {(&/2>*/(,~big'?x),,#:'=x)}
two: solve {3>*/#:'=x@&~big'x}
/

Advent of Code in K, day 11 

f: "11.txt"
init: {0$'x}' 0:f
u: 1!
d: -1!
l: u'
r: d'
pad: {top,x,top:,(#*x)#0}@{0,x,0}'
unpad: {x' x y}@{1_ (-1+)#x}
adj: {unpad@+/1_{y x}\(pad[x];l;u;r;r;d;d;l;l)}
flash: {fl: (~y)&9<x; (x + adj fl; fl|y)}
after: {(*x)*~9<*x}
fix: {[f;a] :[a ~ b:f a; b; _f[f;b]]}
step: {[n;s] done: fix[{flash/x};(1+s; s-s)]; (+//done[1];after done)}
one: +/*:'{y x}\(,(0;init)),100#(step/)
all: {x*x}@
two: {n:0; while[all>*x; n+:1; x:step/x]; n}(1;init)
/

Advent of Code in K, day 10 

f: "10.txt"
lookup: {x[1;*&y=*x]}
nest: "([{<>}])"
err: 3 57 1197 25137
val: lookup (,nest),,{x,|-x}err
input: ({:[0>*x; x; y>0; y,x; y=-*x; 1_ x; y,x]}/val')'0:f
one: -+/,/{x@&{1>*x}x}'input
compl: lookup (,err),,1+!4
two: *(()%2)_ s@<s:{{y+5*x}/compl'x}'input@&{0<*x}'input
/
/ janstepien.com/2021/aoc/
/ See you live on Twitch tomorrow at 14:00 CET?

Advent of Code in K, #9 

f:"9.txt"
max:9
body:{|max,|max,0$'x}'0:f
top:,(#*body)#max
map:|top,|top,body
offs:({x!'map}'-1 1),{x!map}'-1 1
lows:&/map</:offs
one:+/1+,/{y@ x+&x#y}[#*map]'+(+lows),+map
maxat:{(y#x),(,(z#r),max,(z+1)_ r:x[y]),(y+1)_ x}
steps:,/-1 1*\:(1!)\1 0
rec:{r:search[x[1]]/y; ((*x)+*r;*1!r)}
dfs:{rec/((,(1;x)),(y,z)+/:steps)}
search:{:[max=x[y;z]; (0;x); dfs[maxat[x;y;z];y;z]]}
seeds:,/{(*x),'*1!x}'+(,!),(,&:'lows)
two:*/3#a@>(a:((search[map]/)'seeds)[;0])
/

adventofcode 

s:{y@{1+y+!x-(1+y)}':-1,&x=y,x}
ssv:s" "
in:s["|"]'0:"8.txt"
ps:{
sg:{y=+/'x}[x]
on:{x@*&sg@ y}@ x
p3:x@*&3=+/'x&\:~p1:on[2]
s5:sg 5
s6:sg 6
p2:x@*&s5&+/'x&\:~(p3|p4:on[4])
p5:x@*&s5&+/'x&\:~(p2|p7:on[3])
p9:x@*&s6&~+/'x&\:(p2&~p3)
rm:{x@*&z=+/'x&\:y}[x@&s6&~(p9~)'x;p1]'!3
(rm@ 2;p1;p2;p3;p4;p5;rm@ 1;p7;:on[7];p9)
}
wi:{(+/+"abcdefg"=\:x)}
dc:{(+/(0,x)*|()(10*)\1)}
one:+/(#:'=l@<l:#:',/ssv'in[;1]) 1 2 3 6
two:+/dc'{p:ps[wi'1_|ssv@*x];,/{&y~/:x}[p]'wi'1_ ssv@*1!x}'in
/

#adventofcode in K, day 7 

csv: {y@{1+y+!x-(1+y)}':-1,&x=y,x}[","]
pos: 0$'csv@*0:"7.txt"
f: {(x*1!x)%2}@!|/pos
one: +/ _abs pos - {x@(<x)@()%2} pos
two: +/ f@ _abs pos - {(+/1,x)%} pos

/ janstepien.com/2021/aoc/
/

#adventofcode in K, day 6, incl. a link to an RSS feed if that's what you're into 

csv: {y@{1+y+!x-(1+y)}':-1,&x=y,x}[","]
init: -1+(#:'=(!9),0$'csv@*0:"6.txt")
gen: {(6#0),(x,0,x)}
iter: {:[n:*x;(1!x)+gen n; 1!x]}
live: {+/ x iter/init}
one: live 80
two: live 256

/ Part of the series
/ janstepien.com/2021/aoc/

#adventofcode in K, day 5, including a live coding session 

file: "5.txt"
split: {y@{1+y+!x-(1+y)}':-1,&x=y,x}
input: {(0$')'split[","]'(split[" ";x])[0 2]}'0:file
len: {(|/{_abs x}'(-/x))}
hov: {(+/(0=)(-/x))}
points: {(len x)(((-/x)%len x)+)\x@1}
nondiag: input@&hov'input
count: {+/{1<}'=,/points'x}
one: count nondiag
two: count input

/ See the live coding session at
/ twitch.tv/videos/1225134274
/

Show older
Mastodon

The original server operated by the Mastodon gGmbH non-profit