j

iw: 20210504t040000
lu: 20220602t110303

I've decided to continue learning J. I had months ago heard about it somwhere, then forgot or got up other stuff, etc., etc. Installation via instructions provided in the wiki to access newest version. There are 2 IDEs, it runs on Android, iOS, GNU/Linux, Windows, there's a REPL, there's a JS-based one for the web, and ones for IRC (s. wiki, for all of these). Resources include:

Alternative attempts will be numbered in comments. And code comments themselves: SOON™.


NB.pe001
+/@~.@(#~(+/@(0&=)@(3 5&|)@,:]))i.1e3

NB. https://projecteuler.net/problem=002 fixme
x:+/@(0&=@(2&|)#])@(4e6&>#])(1:`((],+/@(_2&{.))@$:@<:)@.*)1e2e

NB. https://projecteuler.net/problem=003 fixme
>./q:600851475143

NB.pe004
(>./@(((*/@(=|.)@":)"0)#])@,@(]*/]))1e2+i.9e2

NB. https://projecteuler.net/problem=012 fixme
div1=:13 :'1{(0=q-<.q)#q=.y%(1+i.y-1)' NB. 1
div2=:13 :'(0=q-<.q)#q=.y%(2,>:@+:@i.@<.@(%&2))y'NB. 2

NB.pe005
<./((0&=@(+/"1@:((>:i.20)&|)"0))#])(*/}.~.0{"1(q:>:i.20))*>:i.1e2 NB. num should contain prime factors at least once

NB.pe006
(*:@:(+/)-+/@:*:)@:>:i.1e2

NB.pe007
p:1e4 NB. fixme

NB.pe008
(>./@:((13&(*/)\)@"."0))'73167176531330624919225119674426574742355349194934969835203127745...'

NB.pe013
":!.11+/q=:... NB. 1 no fucking clue what the fuck q was
((i.10)&{ @ ": @ x: @ (+/))NB. 2 copy list, then `xclip -i | tr \\n \  | xclip` and paste in

NB.pe014
q=:3 :0 NB. 1
if.1&<@:{:y
do.((],(((-:@:[*0=2&|)+(>:@:(3&*)@:[*1=2&|))@:{:)))y
else.]y end.
)
w=:(#@:~.@:(q^:_))"0
e=:w i.1e6
((>./e)=e)#i.1e6
((((([)`((((-:)`([:>:3&*)@.(2&|))@:(0&{)),([:>:(1&{)))@.((1&=)@:(0&{)))^:_1)@:(,&0))"0)NB. 2

NB.pe016
+/("."0@":)x:(2^1e3)

NB.pe009
q=:3 :0
a=.<:y+i.(1e3-y)
s=.0=(a*(a-1e3))+(y*(y-1e3))+(a*y)-5e5
if.1=+./s do.(s#a),y end.
)
q(1&|.)^:(i.1e3)(i.1e3)

NB.pe029
#~.,(q&^)"0 q=:>:>:i.99

NB.pe030
<:+/((((+/@:(^&5)@:>@:((,.&.":)&.>))=[)"0) i.1e6)#(i.1e6)

NB.pe034
(3&-)+/((((+/@:!@:>@:((,.&.":)&.>))=[)"0)i.1e6)#(i.1e6)

NB.pe035
+/@:(*/@:(1&p:)@:~.@:(((1&|.)&.":)^:(>:i.5))"0)((-.@:(+:/@:(0&=)@:>@:((,.&.":)&.>))"0)#])p:i.(_1 p:1e6)NB. 0s result in repeating lesser primes

NB.pe040
q=:":@:,@:((":)"0)i.1e6 NB. strings of variable lens not easily concd

NB.pe123
((((<:@:p:@:<:^[)+(>:@:p:@:<:^[))|~*:@:p:@:<:)"0)>:i.1e5 NB. NaN error?
(((<:@:p:@:<:&^[)+(>:@:p:@:<:&^[)|~*:@:p:@:<:)"0)>:i.1e3 NB. yields 2 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 ... Bolano would be happy, ffs
((((<:@:p:@:<:^[)+(>:@:p:@:<:^[))|~*:@:p:@:<:)"0)>:i.1e5 NB. this should be the answer, but after the first 9 it's all 0s
<./@:(#&(>:@:(_1 p:1e6))q=:(1e10&<@:(((<:@:p:@:<:^[)+(>:@:p:@:<:^[))|~*:@:p:@:<:)@:x:@:>:@:i.)(_1 p:1e6)

NB.pe056
+/@:>@:((,.&.":)&.>)x:!.0(4^12)
([,:)^:(i.[) (i.5)
(([,:)^:(i.[)(i.5)) *"2 (i.5)...
>:>./,+/"1@(,.&.":)"0,.@,@x:@((((#,#)$])^])@:>:@i.)1e2 NB. 2

NB.pe015
(*/21&+i.20)%(*/>:i.20)

NB. https://projecteuler.net/problem=759 fixme
q=:(((((2+%)*$:)@-:@<:)+]`(+:@$:@-:))@.2&|)`1:@.1&=
7&+1e9|(+/@:*:q@:>:@i.)(x:1e16)

NB.pe100
p100=:3 :0 NB. 1; if inequality born from the ratio unmet, searches for increments either head or tail fixme stack error
q=.+:@(*<:)@{.y
w=.(*<:)@+/y
if.q=w do.<"0@(],+/)y
elseif.q>w do.p100((0 1)+y)
else.p100((1 0)+y) end.
)
q=:(+:@(*<:)@{.) NB. 2 stack error
w=:((*<:)@+/)
a=:((a@((1 0)+])`(a@((0 1)+]))@.(q>w))`(<"0@(],+/))@.(q=w))

q=:{{(i.@<.@-:y)&{@:(|.,.])@:>:@i.y}}"0 NB. 3 out of memory
w=:{{{.@((1r2&=)#(y&*@1:))(%/)@(*/)@(,:<:)@({.,+/)"1 y}}
(((0&<)#])@,@:(w@q)) 1e12&+@>:@i.1e2 
q=:{{ NB. 3 stack error
x=.x:x
if.1r2=(x%(x+y))*((<:x)%(<:x+y))do.
x
elseif.x<y do.
(x+y-1)q 2
else.
(x-1)q(y+1)
end.
}}
1e12 q 2

NB.pe044
p=:-:@(3&*@*:-])"0
P=:(0:`{.@.(>.=<.))@{.@({:@:>@p.@(_1&*@+:,_1:,3:))"0
q=:}:@(],.(>:@i.))"0
(<./@(-/"1)@((*./@:*)"1#])@(P@(+/,-/)"1@:p@q)) NB. slow

NB.pe045
t=:-:@(*:+])"0
P=:(_.&*`{.@.(>.=<.))@{.@({:@:>@p.@(_1&*@+:,_1:,3:))"0
H=:(_.&*`{.@.(>.=<.))@{.@({:@:>@p.@(_1&*@],_1:,2:))"0
{.@}.@~.@:(0:`]@.(0&<@H*.0&<@P)@t)286&+i.1e5

NB.pe046
(12&=@#@~.@,@:q:)
(_.&*`]@.(12&=)@#@~.@,@:q:@:((i.@4:)+]))
~.@,@:((0:`]@.(12&=)@#@~.@,@:q:@:((i.@4:)+]))"0)
((((12&=)@#@:q:@((i.@4:)+]))"0)#])>:i.1e3

NB.pe036
ip=:*./@:(({.={:)"1@:{~((,.-@>:)@i.@<.@-:@#)) NB. is palindromic, lol, you suck, nigga
NB. 04+/@~."1@:(0:`(0:`]@.(ip@#:))@.(ip@(,.&.":))"0) i.1e6
1e10|+/@([:(]^])([:>:i.))@x:1e3

NB. https://projecteuler.net/problem=049 fixme
q=:(]#~999&<)q N.????q=:p:(>:i._1 p:9)

NB.pe057
+/({.>{:)"1#@":"0@x:(({:,0:)+(+/))^:(i.1e3)(x:1 1)

NB.pe053
(+/@,@:(1e6&<@((!@{.)%((!@{:)*(!@({.-{:))))"1@(],.>:@i.)"0))>:i.1e2

NB.pe055
+/@:-.50(q=:{{(((<:x)&q@])`0:@.(0=x))`1:@.(*/@(=|.)@":)@(+(|.&.":))x:y}}"0)i.1e4

NB. https://projecteuler.net/problem=059 fixme
a.&i.q
a.{~(i.??(17 b.)

NB.pe063
+/(3 :'(+/@(((10^(<:y))&<:)*.((10^y)&>))@((>:i.9)^]))y')"0 i.25

NB.pe778
q=:4 :'x((9+1e9)&|@((('' ''&~:)#])&.":)@(]`(_1&{&.":)@.(9&<)"0@(*&("."0@":))))y'
vari=:[{."_1]A.~#@:]([(]*i.@:%)&!-)[ NB. https://code.jsoftware.com/wiki/Phrases/Sets
w=:4 :'x+/@(q/"1@~.@vari(,])@(>:@i.))y' NB. works for small x y domain error on vari---find/devise more efficient gen, slow for 7 w 5

NB.pe040
*/"."0((10^i.6)&{@(' '&~:#])@":)i.10^(($:@>:)`]@.(6&<:@#@":@(+/)@:(((10&^)-(10&^@<:))*])@x:))1 NB. log10 of integers to generate for at least 1e6 digits

NB.pe041
>./@(((*./@:((>:@i.@#)e.("."0)))@":"0)#])p:i.(_1 p:2e9)

NB.pe076
p=:3 :0"0
if.0=y do.1:y
elseif.0>y do.0:y
else.
NB. (({.+i.@>:@-~/)@(>.@%&_6@<:,<.@%&6@>:)@%:@>:@*&24)
NB. +/@:p/(((*&_1@>:@i.@{.),(>:@i.@{:))@(>.@%&_6@<:,<.@%&6@>:)@%:@>:@*&24)y
NB. (+/@:p@:((*&_1@>:@i.@{.),(>:@i.@{:))@(>.@%&_6@<:,<.@%&6@>:)@%:@>:@*&24)y

for_k.(((*&_1@>:@i.@{.),(>:@i.@{:))@(>.@%&_6@<:,<.@%&6@>:)@%:@>:@*&24)y do.
(p(y&-@-:@    3*k^2-k   ))*_1^(k+1)

+/@:(((p@(-&y)@-:@(*(<:@*&3)))*(_1:^>:))"0@((*&_1@>:@i.@{.),(>:@i.@{:))@(>.@%&_6@<:,<.@%&6@>:)@%:@>:@*&24)y 
end.
end.
)

(((+/@:p@:((*&_1@>:@i.@{.),(>:@i.@{:))@(>.@%&_6@<:,<.@%&6@>:)@%:@>:@*&24)`0:)@.(0&>))`1:@.(0&=)
(#@~.@("."0@":@,))q NB. min amount of digits
(i.9)(]-.~-.)((~.@("."0@":@,))q)NB. missing numbers

NB.pe079
q=:NB. xp -o|tr \\n \ |xp

NB.pe193
8&+@(+/)@:((+./@:=&0@(|~((*:@p:@i.@(_1&p:)@(_4&p:)@%:))))"0)11&+i.2^50 NB. 1 limit error don't look up primes for each number, ffs
((*:@p:@i.@(_1&p:)@(_4&p:))2^25)([:<:[:#[:~.[:,[*(>:@i.@<.@(]%[)))2^50 NB. 2 limit error aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
{{for_q.(*:@p:@i.@(_1&p:)@(_4&p:)@%:)2^50 do.w=:~.@(w&,)@(q&*)@>:@i.@<.2^50%q end.}}w=:0 NB. 3 ???
{{for_q.(*:@p:@i.@(_1&p:)@(_4&p:)@%:)2^50 do.w=:w,((q&*)@>:@i.@<.2^50%q)end.}}w=:0 NB.4 ???
(#@~.@,@{{(((>:@i.@<.(y&%))*])@*:@p:@i.@(_1&p:)@(_4&p:)@%:)y}})2^50 NB. 5 limit error

NB.pe065
(+/@("."0@>@{.@(<;._1)@('r'&,)@":))@+&2@(3 :'(((1:%({.+($:@}.)))`(x:@%))@.(1:=#))y')(99&{.(1,([,1,1,])/+:@>:@i.4e1)) NB.1
(+/@("."0@>@{.@(<;._1)@('r'&,)@":))(+%)/x:(100&{.(2,1,([,1,1,])/+:@>:@i.4e1)) NB. 2

NB. https://projecteuler.net/problem=796 fixme
q=:(!@{.%!@{:*!@-/)"1 NB. binomial coefficient    (x: q 54 13) * w -: 4  NB. exactly 4 suits
(]i.(>./))(q (54,.(13+i.41)))*(w0*42%(41+ -i.41)) NB. amount of combinations * chance for full suit + extra cards      index of greatest number, that is, with highest probability; 15
w0=:x:*/%/"1(13 2$ 52 54 12 53 11 52 10 51 9 50 8 49 7 48 6 47 5 46 4 45 3 44 2 43 1 42) NB. P 13 of same suit sequentially
(q 54,c) * (w0*42%(42-c)) NB. solve c for maximum, somehow

NB.pe074
([:+/60&=@{{$:`#@.([:+./{.E.}.)@(q,])y}}@(q=:[:+/ x:@!@"."0@":@{.)"0)i.1e6

NB.pe043
([:+/".@(([:(7#0)&-:|~&(p:i.7)@([:}.3".\":))#])"1)@(i.@!@#A.i.@#C.])'0123456789'

NB. https://projecteuler.net/problem=698 fixme
is123=:{{)m(  "."0@":)y}} 
([:+/((1,2,3)&e.@])@"."0@":)1112            (((1:,2:,3:)e.])@"."0@":) 1112
   (3 3 3 3 3 #: i.30)

NB. https://projecteuler.net/problem=254 fixme
f=:([:+/!@"."0@":)
s=:([:+/"."0@":)

NB. https://projecteuler.net/problem=080 fixme
("."0@":x:!.0@*&1e100@%:)1e2

NB. https://projecteuler.net/problem=064 fixme
(([:+/(2&|)@{{$:`(<:@#)@.({.e.}.)@((1&|@%@{.),])y}}"0@(~:&0#])@(1&|)@:%:))>:i.1e4 NB. 1 fails ultimately bc. of comparison tolerances
(([:+/(2&|)@{{$:`(<:@#)@.([:+./{.(1e_3(1 :'|@-<:!.0 m*>.&|'))}.)@((1&|@%@{.),])y}}"0@(~:&0#])@(1&|)@:%:))>:i.1e4 NB. 2 https://code.jsoftware.com/wiki/Essays/Tolerant_Comparison#Models
(([:+/(2&|)@{{$:`(<:@#)@.([:+./{.(1e_4(1 :'|@-<:!.0 m*>.&|'))}.)@((1&|@%@{.),])y}}"0@((0&<@(1&|))#])@:%:))>:i.1e4 NB. 3 ???

NB. https://projecteuler.net/problem=487 fixme
+/(p:({.+i.@{:)({.,-~/)(p:^:_1)4 p:(],2e3&+)2e9)|1e4([:+/[:+/]\@:>:@i.@]^[)1e12 NB. 1
+/(p:({.+i.@{:)({.,-~/)(p:^:_1)4 p:(],2e3&+)2e9)|([:+/@:((>:@i.@-@#)*])>:@i.@{.^{:)1e12 1e4 NB. 2 big nombr make memori go kthxbai

NB. https://projecteuler.net/problem=160 fixme
({{((-@>:@i._5)&{`($:@}:))@.(=&'0'@{:)y}}@":@x:@!)1e15
{{(-@>:@i._5)&{`($:@}:)@.(=&'0'@{:)y}}@":@!x:!.0(1e15)

NB.pe050
({.@((>./@/:@{:@|:){])@(1&p:@{.#])@(1e6&>@{.#])@,@([:(+/,([:+/#@>&0))\"1($$(([:,<:/~@(>:@i.@#))*,))@((1&|.)^:(i.@#))@p:@i.@(_4&p:)))1e6

NB.aoc2101
(+/@(2({.<{:)\]))

(+/@(2({.<{:)\]@3(+/)\]))

NB.aoc2102
q=:w=:0
f=:3 :'q=:q+y'
u=:3 :'w=:w-y'
d=:3 :'w=:w+y'

q=:w=:e=:0
f=:3 :0
q=:q+y
w=:w+(e*y)
)
u=:3 :'e=:e-y'
d=:3 :'e=:e+y'

NB.aoc2103
*/#.(|:@(],.-.))(500&<@(+/)@((":)^:_1)@,.)"1|:1e3 12 NB.$(xclip -o | tr -d \[:space:\])

g=:|:@(500&<:@(+/)@((":)^:_1)@,.)"1|:1e3 12$ a
e=:|:@-.@(500&>@(+/)@((":)^:_1)@,.)"1|:1e3 12$ a

NB.g(((0&{ @ [)=@ 0&{)"1#]){1e3 12 NB.$(xclip -o | tr -d \[:space:\])
NB.  ^---consequetive number of g  ???

NB.aoc2104
boards=:(((5&%~@#),5:,5:)$])q

update=:(*(numFromQ&~:))boards

(17 b.)/"1 @ (23 b.)/"1 (boardNum{boards)
(17 b.)/"1 @ (23 b.)/"1 (|:boardNum{boards)