LdBeth · @ldbeth
133 followers · 724 posts · Server mastodon.sdf.org
Alexander Shendi · @alexshendi
154 followers · 1768 posts · Server rollenspiel.social
Jan Stępień · @jstepien
192 followers · 94 posts · Server mastodon.social

f:"15.txt"
n:2000000
c:"-",,/$!10
i:{2 2#.`c$(" "*~i)+x*i:+/c=\:x}'0:f
a:{x|-x}
d:{+/a x-y}
m:{$[~~#:i:&x[0;1]>-2+1_x[;0]
(,x[0;0],|/x[0,1+*i;1]),x[(!#:x)^0,(1+*i)]
x]}
r:{cl:i@&{d[1_x;x[1],y]<1+*x}[;x]'(d.'i),'*+i;
r@<*+r:{x[1]+(-s)+0,2*s:x[0]-a y-x[2]}[;x]'(d.'cl),'*+cl}

--/*m/r[n]

x+4000000*1+*|*m/r[x:*&1<#'(m/r@)'!n*2]

/ Takes five minutes using
/ codeberg.org/ngn/k

/ There must be a better way

/

#k #apljk #apl #adventofcode #arrayprogramming

Last updated 2 years ago

Jan Stępień · @jstepien
190 followers · 90 posts · Server mastodon.social

/ read & parse
v:!#:i:0N 7#(,""),0:"11.txt"
s:(.18_)'i[;2]
n:19_'i[;3]
a:$*/.'d:(*|" "\)'i[;4]
t:|'(.*|)''i[;5 6]

/ simians → functions
sf:{."{[old](,w),,t[",($x),"]@~",(d x),"!w:",a,"!_(",n[x],")%rf}"}'v

/ turn, round, play
tr:{@[y;x;0#],'*'(t[0]@&)''(!#:y)=\:1_t:sf[x;y[x]]}
rn:{x{tr[y;x]}\!#:x}
pl:{*/t 2#>t:+/(m# v){y*x=v}'(m:(#:i)*x)##''h,,/(h:,s){y; rn@*|x}\!x}

/ relief factor and round no.
rf:3
pl 20

rf:1
pl 10000

/

#k #apljk #apl #adventofcode #arrayprogramming

Last updated 2 years ago

Jan Stępień · @jstepien
189 followers · 89 posts · Server mastodon.social

/ The screen size
(h;w):s:6 40

/ The cycles that matter
c:20+w*!h

/ This parses our input
p:{$[x[3]="x";(`I$5_x),0;,0]}

/ Parts one and two
+/c*(r:+\1,,/p'0:"10.txt")c-2
(`0:" #"(!w){3>d*d:y-x}')'s# 1,r;

/ How about another live solving stream this Monday?
/ twitch.tv/janstepien

/

#k #apljk #apl #adventofcode #arrayprogramming #programming

Last updated 2 years ago

Jan Stępień · @jstepien
189 followers · 89 posts · Server mastodon.social

/ The screen size
(h;w):s:6 40

/ The cycles that matter
c:20+w*!h

/ This parses our input
p:{$[x[3]="x";(`I$5_x),0;,0]}

/ Parts one and two
+/c*(r:+\1,,/p'0:"10.real")c-2
(`0:" #"(!w){3>d*d:y-x}')'s# 1,r;

/ How about another live solving stream this Monday?
/ twitch.tv/janstepien

/

#k #apljk #apl #adventofcode #arrayprogramming #programming

Last updated 2 years ago

Jan Stępień · @jstepien
187 followers · 87 posts · Server mastodon.social

i:`I$''0:"8.txt"

/ external view from left side
v:{1_|1_|+1_|2_|+(x,\:0)>(|\0,)'x}

/ count trees on the edges
e:4*-1+#:i

/ count trees visible from the left side
m:|~0=!-1+#:i
l:{1+(*&)'~((m&1_)'(*'x)>x)}

/ count trees visible to the right in the
/ entire forest
f:{+(|!#:x)&{l@(y_(y+s:#:x)#)'x}[x]'!#:x}

/ invoke x with all four rotations of y
a:{(4-y)(+|:)/ x y(+|:)/i}

e++//|/a[v;]'!4
|//*/a[f;]'!4

/

#k #apljk #apl #adventofcode #arrayprogramming #programming

Last updated 2 years ago

Daniel · @semperos
72 followers · 26 posts · Server fosstodon.org

I discovered the ArrayCast this week and have enjoyed it tremendously.

arraycast.com/

Fun content for nerds; positive and constructive perspectives; and soothingly orderly conversations where folks don’t interrupt each other 😌

#podcast #programming #language #apl #jlang #klang #forth #arrayprogramming

Last updated 2 years ago

Jan Stępień · @jstepien
187 followers · 84 posts · Server mastodon.social

e:{(" "\x) y}
a:{(,x,(,"/"),*y),y}
c:{n:e[y;2];@[x;0;$[n~,"/";{,,"/"};n~"..";1_;a[n]]]}
d:l:{y; x}
s:{.e[y;0]; @[x;1;((`$'*x)!(#*x)#.e[y;0])+]}
f:{."clds"@*&("clr"=x[2]),1}
d:(!0;`!!0){(f y)[x;y]}/i:0:"7.real"
+/v@&~100000<v:.*|d
g:40000000
t@*<t:-:g-r+t@&0<t:(.m)+g-r:(m:*|d)@`"/"

/ Fold the input lines using a dynamic dispatch
/ and keeping the directory sizes in a dictionary.

/ The language is growing on me.

/

#k #apljk #apl #adventofcode #arrayprogramming #programming

Last updated 2 years ago

Jan Stępień · @jstepien
183 followers · 81 posts · Server mastodon.social

{x+(*&x=(#=)'x':)'0:"6.txt"}'4 14

/ Run it with either
/ codeberg.org/ngn/k
/ or
/ johnearnest.github.io/ok/

/ Watch the stream recording at
/ twitch.tv/videos/1671764330

/

#k #apljk #apl #adventofcode #arrayprogramming

Last updated 2 years ago

Jan Stępień · @jstepien
181 followers · 80 posts · Server mastodon.social

Today's Advent of Code problem doesn't look like it will take us a lot of time. Let's take this opportunity, and explain every step of solving it in K. Nice and beginner friendly.

See you at noon UTC+1 at twitch.tv/janstepien

#adventofcode #apljk #arrayprogramming #streaming #livecoding #programming

Last updated 2 years ago

Jan Stępień · @jstepien
180 followers · 79 posts · Server mastodon.social

s:(+((-1+h:*&0=#'i)# i:0:"5.txt")[;1+4*!9])^'" "
m:+0 -1 -1++`I$''(" "\'(h+1)_i)[;1 3 5]
t:{@[y;z[2];(x@(*z)# y[z[1]]),]}
d:{@[x;y[1];(*y)_]}
f:{*'s{d[;y]t[z;x;y]}[;;x]/m}
f[|:]
f[::]

/ We _might_ be having another stream tomorrow
/ at noon UTC+1 → twitch.tv/janstepien

/

#k #apljk #apl #adventofcode #arrayprogramming

Last updated 2 years ago

Jan Stępień · @jstepien
180 followers · 78 posts · Server mastodon.social
Jan Stępień · @jstepien
180 followers · 75 posts · Server mastodon.social

s:{x+!1+y-x}.`I$
p:s'"-"\'
i:p'","\'0:"4.txt"
+/{|/0=#'(y^x;x^y)}.'i
+/{0<#:x^x^y}.'i

/ This solution to day three helped me a lot here:
/ codeberg.org/ngn/k/src/commit/

/ How about another live stream tomorrow at noon UTC+1?
/ twitch.tv/janstepien

/

#k #apljk #apl #adventofcode #arrayprogramming

Last updated 2 years ago

Jan Stępień · @jstepien
180 followers · 75 posts · Server mastodon.social

s:{x+!1+y-x}.`I$
p:s'"-"\'
i:p'","\'0:"4.txt"
+/{|/0=#'(y^x;x^y)}.'i
+/{0<^x^y}.'i

/ This solution to day three helped me a lot here:
/ codeberg.org/ngn/k/src/commit/

/ How about another live stream tomorrow at noon UTC+1?
/ twitch.tv/janstepien

/

#x #k #apljk #apl #adventofcode #arrayprogramming

Last updated 2 years ago

Jan Stępień · @jstepien
179 followers · 74 posts · Server mastodon.social

Streaming AoC day 4 at 19:00 UTC+1. This time on a Raspberry PI. Tune in and partake in some merry array programming!

twitch.tv/janstepien

#k #apljk #apl #adventofcode #arrayprogramming #live

Last updated 2 years ago

Jan Stępień · @jstepien
177 followers · 73 posts · Server mastodon.social

in:0:"3.txt"
p:{+//((,u),,~u:"a">x)*27 1+x-/:"Aa"}
s:{,/((y,/:x).)@&x=\:y}
p@{*s[h_x;(h:`i$(#:x)%2)# x]}'in
p@{*s[x;s[z;y]]}.'((`i$(#:in)%3),3)# in

/ I'm afraid my shared item check uses
/ a quadratic amount of memory wrt to
/ the number of elements in rucksacks,
/ but hey, it's weekend.

/ I might stream again tomorrow in the
/ UTC+1 evening. Why not swing by?
/ twitch.tv/janstepien

/

#k #apljk #apl #adventofcode #arrayprogramming

Last updated 2 years ago

Jan Stępień · @jstepien
177 followers · 73 posts · Server mastodon.social

in:0:"3.txt"
p:{+//((,u),,~u:"a">x)*27 1+x-/:"Aa"}
s:{,/((y,/:x).)@&x=\:y}
p@{*s[h_x;(h:`i$()%2)#x]}'in
p@{*s[x;s[z;y]]}.'((`i$()%3),3)#in

/ I'm afraid my shared item check uses
/ a quadratic amount of memory wrt to
/ the number of elements in rucksacks,
/ but hey, it's weekend.

/ I might stream again tomorrow in the
/ UTC+1 evening. Why not swing by?
/ twitch.tv/janstepien

/

#x #in #k #apljk #apl #arrayprogramming #adventofcode

Last updated 2 years ago