Time based One Time Password in #Jlang
#jlang #arrayprogramming #apljk
Shoutout for Decker, a HyperCard-like environment:
https://github.com/JohnEarnest/Decker
https://github.com/1jss/awesome-decker
https://www.arraycast.com/episodes/episode43-john-earnest-decker
Decktember (12/2022) game jam:
https://itch.io/jam/decktember
Kudos to John Earnest!
#Decker #lil #arrayprogramming #hypercard
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
/ https://codeberg.org/ngn/k
/ There must be a better way
#k #apljk #apl #adventofcode #arrayprogramming
/ 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
/ 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?
/ https://www.twitch.tv/janstepien
/ #k #apljk #apl #adventofcode #arrayprogramming #programming
#k #apljk #apl #adventofcode #arrayprogramming #programming
/ 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?
/ https://www.twitch.tv/janstepien
/ #k #apljk #apl #adventofcode #arrayprogramming #programming
#k #apljk #apl #adventofcode #arrayprogramming #programming
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
#k #apljk #apl #adventofcode #arrayprogramming #programming
I discovered the ArrayCast #podcast this week and have enjoyed it tremendously.
Fun content for #programming #language nerds; positive and constructive perspectives; and soothingly orderly conversations where folks don’t interrupt each other 😌
#podcast #programming #language #apl #jlang #klang #forth #arrayprogramming
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
#k #apljk #apl #adventofcode #arrayprogramming #programming
{x+(*&x=(#=)'x':)'0:"6.txt"}'4 14
/ Run it with either
/ https://codeberg.org/ngn/k
/ or
/ https://johnearnest.github.io/ok/
/ Watch the stream recording at
/ https://www.twitch.tv/videos/1671764330
#k #apljk #apl #adventofcode #arrayprogramming
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 https://www.twitch.tv/janstepien
#adventofcode #apljk #arrayprogramming #streaming #livecoding #programming
#adventofcode #apljk #arrayprogramming #streaming #livecoding #programming
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 → https://twitch.tv/janstepien
#k #apljk #apl #adventofcode #arrayprogramming
Another K AoC stream today at noon UTC+1.
https://twitch.tv/janstepien #adventofcode #arrayprogramming #apljk #k #apl
#adventofcode #arrayprogramming #apljk #k #apl
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:
/ https://codeberg.org/ngn/k/src/commit/7c0042e88/aoc/22/03.k
/ How about another live stream tomorrow at noon UTC+1?
/ https://twitch.tv/janstepien
#k #apljk #apl #adventofcode #arrayprogramming
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:
/ https://codeberg.org/ngn/k/src/commit/7c0042e88/aoc/22/03.k
/ How about another live stream tomorrow at noon UTC+1?
/ https://twitch.tv/janstepien
#x #k #apljk #apl #adventofcode #arrayprogramming
Streaming AoC day 4 at 19:00 UTC+1. This time on a Raspberry PI. Tune in and partake in some merry array programming!
#k #apljk #apl #adventofcode #arrayprogramming #live
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?
/ https://twitch.tv/janstepien
#k #apljk #apl #adventofcode #arrayprogramming
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?
/ https://twitch.tv/janstepien
#x #in #k #apljk #apl #arrayprogramming #adventofcode