j

iw: 20210504
lu: ????????

I've decided to continue learning J. I had months ago heard about it somewhere, then forgot or got up to other stuff, among other excuses. Installation via instructions provided in the wiki to access newest version. There exists an IDE called JQt. It runs on Android, ARM, iOS, GNU/Linux, Windows. Resources include:

Alternative attempts will be enumerated in comments; fixmes indicate incomplete problems and or unsatisfactory solutions. If your teeny-tiny brain can't handle opening and reading one of the above, I've written a small introduction.


My suboptimal, incomplete introduction to J Firstly, beware, the linguistic analogy is loose, (Western) European, and incomplete or too contingent. Don't bully it too-too much.
A statement in J is called a 'sentence' (S). It terminates with a(n OS-independent) newline, and its constituents are called 'parts of sentence' (PoS). The predefined, canonical, keyword are called primitives. 'NB.' is one such, an initialism of the Latin 'nota bene', literally 'note well', used to start comment a comment until end of line. J's REPL uses an indentation of 3 spaces for user input, which I'll use here only; computation results are without. Lastly, along with all the other array programming languages, J parses: 1, from right to left; 2, without operator precedence, though parentheses take precedence, and I'll be using these to either explicate tacit code or to emphasise; and 3, usually greedily (read more about parsing in the wiki, which PoS gobble 1, which more...):

   - / 1 2 3 4 NB. = 1 - 2 - 3 - 4 = 1 - (2 - (3 - 4))
_2
   11 * 0 + 3
33

Lastly, to forgo umpteen resolves-tos and equals, I'll use the J dyadic primitive for 'match' (or exact copy; it takes shapes into account) '-:', which returns 0, false, or 1, true, to denote equality in value, parsing, result, or something else. I'll be giving examples of the PoS or concept and or of their usage.

   0 1 2 3 = 5 1 2 4
0 1 1 0
   0 1 2 3 -: 5 1 2 4
0

A noun (N) is a constant, a literal, an object, usually mathematical one: ±∞, numerics (booleans, reals, rationals, complexes, integer-based, real-based, pi-based, radian-based, degree-based), strings (char array, though there is extended precision to UTF-4 and UTF-8, and with the unicode primitive 'u:'), boxes (a container type), all of any shape (a list (a 1-dimensional array) of non-negative values, roughly corresponding to something like a reduced matrix' column, row, and so on ranks, in a predefined order, always starting from row, something called being row-major⸻for a comparison of some languages' features, see here) or nestedness (boxes in boxes in ...), in addition the a special kind called a symbol, which is like a boxed string, but with special properties. All these are either scalars or arrays. The first haven't a shape (J has decided that shape of '0', or '0 0 0 ...' doesnot a scalar make, and I agree based on how I think of spaces. These despite their 0 length in each dimension or along each axis, exist in an #@\$-dimensional space.), the second do. The canonical left and right nominal arguments that are acted upon in definitions, covered later, are x and y.

   'Hello, world.' NB. N of shape of 13
'Hello, world.'
   1 2 3 NB. N of shape 3
1 2 3
   (0 $ 1) -: 1 NB. scalars are shapeless
0
   ('' $ 1) -: 1
1
   (1 $ 1) -: 1 NB. arrays are not
0
   i. 2 NB. (V N) -: (N).
0 1
   {{1 + y}} 1 _ NB. V direct definition
2 _

A verb (V) is like a function in that it does somethingto something, that is, a noun. In J, verbs are 'nulladic', 'monadic', or 'dyadic' (words referring their arity, the number of arguments they accept, here 0, 1, 2), depending on the primitive, or your V definition. Examples:

   >: i. 2 3 NB. increment (by one) integers (of shape y)
1 2 3
4 5 6
   i: 4 NB. 'steps', or integers with their negatives
_4 _3 _2 _1 0 1 2 3 4
   2 ^ i:4 NB. exponentiation
0.0625 0.125 0.25 0.5 1 2 4 8 16
   % 5 10 20 NB. reciprocal
0.2 0.1 0.05
   */ $ i. >: i.10 NB. number of elements in array of shape 1 2 ... 10
3628800

An adverb (A) is a first-order higher 'function'. It either modifies how its left verb, u, operates, that is, (V A) -: (V'). (Because of which they're also commonly written without a separating space even by clean coding veterans.), or it creates a noun according to m (and x). Good place to mention that m and n are the (named of the) canonical left and right auxiliary nouns.

   i. 3
0 1 2
   ] \ i. 3 NB. monadically same (identify), dyadically right using prefix
0 0 0
0 1 0
0 1 2
   2 ^ 3
8
   2 ^ ~ 3 NB. reflex, exchanges a V's x and y, or copies y in absense of x
9
   (10 * >: i.2) */ (>: i.4) NB. table, returns array having entries (a u b) for every a in x and b in y/x->
10 20 30 40
20 40 60 80
   _ (1 2) } i.4 NB. amend, 'x m} y' amends y by creating a new noun that is a copy of y with the locations m replaced by new values x
0 _ _ 3

A conjunction (C) is second-, third-, or fourth-order higher 'function', taking 2⸺4 PoS and, doing something to or with those, can yield any PoS.

   ((+ & 2) ^: _1) 7 NB. '^:' applies the left V and the right N times; negative reverse
5
   (^ & 2) 3 NB. '&' binds a dyadic V's x or y, creating a monad; beware greediness
8
( 3 6 9 &+ &. |.) 0 1 2 NB. 'under' applies v, then u, then the inverse of v to y (and x); not 3 7 11 (2&* @ 10&-) 3 NB. @, @:, &, &: all compose verbs, diff rank-wise and action-wise different (2&* @ -&10) 4

A train is a predefined sequence of PoS, which combine to a(nother) PoS. Linguistically, this makes no sense, afaik.
A hook is a V-only train, sometimes called a 2-train. V1 preprosseses y before handing it off V2, which is dyadic, and which in absense of an x, copies the original y as the other operand. That is, (x (V1 V2) y) -: (x V2 (V1 y)), and ((V2 V1) y) -: (y V2 (V1 y))

   (2&* 1&+) 3 NB. add 1 from the right, then multiply by 2 from the right (and by self or x)
32
   (* *) _10 0 20 NB. multiply by sign, a primitive absolute value (don't work with complex)
10 0 20

A reverse hook operates similarly but in opposite direction, preprosessing with V2 and dyadically using V1. BQN has a primitive for this, whereas J doesn't. However, we can define one using definitions' left and right Vs:

   + {{v u}} -
- +

A fork is the second type of V train, also called a 3-train. (x (V3 V2 V1) y) -: ((V3 x) V2 (V1 y)) and ((V3 V2 V1) y) -: ((V3 y) V2 (V1 y)). V trains of more than 3 (or resolved PoS) alternate from the right to the left between hooks and forks: (V4 (V3 V2 V1)) is a hook with a preprosessing fork. Additionally, if you wish V2 to be monadic, you may use '[:', called cap, for the first tine of the fork..

   (2&* , 2&%) 4
8 0.5
   (+/ % #) i. 101 NB. average of 0 thru 100; divide sum by length
50
   (< +:) 10 NB. -: (10 < (+: 10)) -: (10 < 2 * 10)
1
   ([: < +:) 10 NB. -: (< (+: 10))
+--+
|20|
+--+

Assignment is done globally with '=:' and locally with '=.'. Direct definitions using '{{...}}' are less of an eyesore and ease use of definitions, be it the explicit multiline one or the inline string one, with the definition verb ':'. Beware, the space before the colon is necessary because of constant functions matching the regex '_?\d:', which return a number.

   q =: 2 (4 :'x + y + 10') 3 NB. dyadic (4) V, explicitly
_5
   w =: (3 : 'y % y ^ y') 4 NB. monadic (3) V, explicitly
0.015625
   0 : 0 4 NB. N (0) explicitly (0), a string
16
   $ q=: 0 :0
1
2
3
) NB. terminating sequence when using ':'
6 NB. 3 digits, 3 newlines
   7 (3) {{ |. ^: (x > y) (x <. y) + (i. 1 + m) * (m %~ | x - y)}} 2 NB. define an adverb to create a noun of length m+1 equidistantly spanning from the less to the greater of both x, y
7 5.33333 3.66667 2
   1 :('|. ^: (x > y) (x <. y) + (i. 1 + m) * (m %~ | x - y)') NB. same using the primitive
   q =: +
   w =: -
   3 : '10 w (x q y)'
3 : '10 w (x q y)'
   13 :'10 w (x q y)' NB. define tacit (13) V, it notices the hook
10 w q
   13 : '10 w (x q y)' f. NB. 'fix' adverb replaces/substitutes variables (once)
10 - +


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

NB.pe002
x:+/@(0&=@(2&|)#])@(4e6&>#])(1:`((],+/@(_2&{.))@$:@<:)@.*)1e2

NB.pe003
>./q:600851475143

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

NB.pe012
div1=:13 :'1{(0=q-<.q)#q=.y%(1+i.y-1)' NB. 1 fixme
div2=:13 :'(0=q-<.q)#q=.y%(2,>:@+:@i.@<.@(%&2))y' NB. 2 fixme
($:@>:`] @.(5e2<([:#(*/ .^"1(#:i.@(*/))@:>:)/@:(__&q:))))M.28 NB. 3 fixme
{{while.5e2>:([:#(*/ .^"1(#:i.@(*/))@:>:)/@:(__&q:))w=.+/>:i.y=.y+1 do.end.w}}499 NB. 4

NB.pe005
<./((0&=@(+/"1@:((>:i.20)&|)"0))#])(*/}.~.0{"1(q:>:i.20))*>:i.1e2 NB. num should contain prime factors at least once
{.(#~([:*./0=(2+i.9)&|)"(0))>:i.1e999 NB. 2
{{q=.2519 while.do.if.([:*./0=(2+i.19)&|)q=.q+1 do.q return.break.end.end.}}'' NB. 3

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

NB.pe007
p:1e4

NB.pe008
(>./@:((13&(*/)\)@"."0))'73167176531330624919225119674426574742355349194934969835203127745...' NB. 1
([:>./13(*/)\[:,"."0@{&a.@,.@(10&~:#])@I.~&a.)2!:0'xclip -o' NB. 2

NB.pe013
((i.10)&{@":@x:@ +/)2!:0'xclip -o | tr \\n \ ' NB. 1
(i.10)&{":x:+/".;._1 LF,2!:0'xclip -o' NB. 2

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

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

NB.pe009 fixme
q=:3 :0 NB. 1
a=.<:y+i.(1e3-y)
s=.0=(a*(a-1e3))+(y*(y-1e3))+(a*y)-5e5
if.1=+./s do.(s#a),y end.
         ( ([:*/ ($ #: (i.&1e3@:*:) @: ,)  (]+/]+/]) ) { ])>:i.50
)
q(1&|.)^:(i.1e3)(i.1e3)
([:*/([:($#:(i.&1e3)@,)]+/]+/]){])*:>:i.1e3 NB. 2
((($#:(i.&1e3)@,)]+/]+/]){])*:>:i.1e2
{{for_q.>:i.1e3 do.for_w.>:i.1e3-q do.for_e.1e3-q+w do.if.(1e3=q+w+e)*.((+/*:q,w)=(e^2))do.q,w,e return.end.end.end.end.}}'' NB. 3

NB.pe029
#~.,(^/])2+i.1e2-1

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
((((<:@: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
([:>:[:>./[:,[:+/"1@(,.&.":)"0,.@x:@((^/])@:>:@i.))1e2 NB. 3

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

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

NB.pe100 fixme gigafail lmao you suck
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))
a 1e12

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. ((>:x)$:y)`(           )@.(0.5&>@{{x(((*<:)@[)%((*<:)@]))y}})
w=:{{if.0.5&<q=.x:x(((*<:)@[)%((*<:)@]))y do.(>:x)w y elseif.0.5&<q do. x w(>:y)elseif.0.5&=q do.x,y end.}}

w=:{{if.0.5&<q=.x:x(((*<:)@[)%((*<:)@]))y do.(>:x)w y elseif.0.5&<q do. x w(>:y)elseif.0.5&=q do.x,y end.}}
(4 :'[,]`[$:(>:@])@.(0.5&>q)`(>:@[)$:]@.(0.5&<q=:x:([(((*<:)@[)%((*<:)@]))]))') NB. noun result req'd

{{)d x,y`x$:(>:@y)@.(0.5&>q)`(>:@x)$:y@.(0.5&<)q=:x:(x(((*<:)@[)%((*<:)@]))y)}}

{{ if.0.5&<q=:x:(x(((*<:)@[)%((*<:)@]))y)do.(>:x)$:y elseif.0.5&>q do.x$:(>:y)else.x,y end.}}
x,y`x$:(>:@y)@.(0.5&>q)`(>:@x)$:y@.(0.5&<)q=:x:(x(((*<:)@[)%((*<:)@]))y)}}
w=:{{ if.0.5&<q=:x:(x(((*<:)@[)%((*<:)@]))y)do.(>:x)w y elseif.0.5&>q do.x w(>:y)else.x,y end.}}

w=:{{ if.0.5<q=:x:x(%&(*<:))y do.(>:x)$: y elseif.0.5>q do.x $:(>:y)else.x,y end.}}

failure
failure
failure
failure
failure
failure
failure
...

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.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.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.pe796 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.pe698 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.pe254 fixme
f=:([:+/!@"."0@":)
s=:([:+/"."0@":)

NB.pe080 fixme
("."0@":x:!.0@*&1e100@%:)1e2

NB.pe064 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.pe487 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.pe160 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.pe120
(>:i.1e3)([:+/([:>./(*:@])|((<:@]^[)+(>:@]^[)))"1 0)(3&+i.998x)

NB.pe119 fixme
q=:{{if.1<z=.([:+/"."0@":)y do.+./y=z^(>:@i.(<.z^.y))else.0:y end.}}"0
{{if.q y do.if.x=1 do. y return.else.(<:x)$:(>:y)end.else.x$:>:y end.}}10
([ $: >:@])`((<:@[ $: >:@])`]@.(1:=[))@.(q)
 2    (3 :'([ $: >:@])`((<:@[ $: >:@])`]@.(1:=[))@.(q)')10

NB.pe235
0j12":>{:p.6e11,(9e2-3*])2+i.5e3-1 NB. obscenely heavy
(I.1&=(_5e3 5e3)I.((6e11,(9e2-3*])2+i.5e3-1)p.z))#z=:1.002(1e6){{(x<.y)+(i.1+m)*(m%~|x-y)}}1.0024 NB. nah
q=:((6e11,(9e2-3*])2+i.5e3-1)&p.)
rbm=:{{ NB. root bisection method
N=.0
M=.1e9 NB. max iterations
t=.1e_14 NB. tolerance
a=.1.0 NB. lower bound
b=.1.1 NB. upper bound
while.N<M do.
c=.-:a+b
if.(0=Q=.u c)+.(t>(-:b-a))do.0j12":c return.end.
N=.1+N
if.Q((=&*) u)a do.a=.c else.b=.c end.
end.
0:y
}}
q rbm ''

NB.pe802 fixme
q=:(((2^~{.)-{.-2^~{:),(1p1-{:+[:+:{.*{:))
F=:{{
N=.0
w=.y
whilst.w~:y do.
w=.q w
N=.1+N
end.
N
}}

NB.pe145 fixme
((([:*./e.&'13579')@":)"0@((0~:])#])@,@:((+(((('0'~:{.)#])@|.)&.":))"0))

NB.pe059 fixme
e=:#q=:".1!:1 <'/tmp/p059_cipher.txt'
{{for_w.a.i.(((26^3),3)$])2!:0'zsh -c "printf %s {a..z}{a..z}{a..z}"'do.
r=.(e$w)(23 b.)q
if.+./32=r do.NB.(([:*./31&<)*.([:*./128&>))r
((w{a.),CRLF,(r{a.),CRLF,'-----------------------------------',CRLF) fappend '/tmp/z'
end.
end.
}}''

NB.pe089
q=:];._1 LF,2!:0'cat p089_roman.txt'
(('IVXLCDM'e.~])#])

NB.pe011
x:>./(([:>./[:([:>./4*/\])(],|:)),([:>./[:([:>./4*/\])/.(],|:)))".;._1 LF,2!:0'xclip -o' NB. 1
>./4*/\;(</.@|.,</.,<"1,<"1@|:)(20 20)&$@".2!:0'xclip -o|tr \\n \ ' NB. 2

NB.pe010
+/p:i._1 p:2e6

NB.pe098 fixme
([:%:[:*/+/,(+/-])) 5 5 6

NB.pe033 fixme
(((]%[)=(((([:-.+./&|:@:="1 0)#])%(([:-.+./&|:@:="0 1)#[))&("."0@":))) #])/"1 ((([:+./'0'&~:@{:@":"0)*.(~:/)"1)#])"1 >,(([:<[,])"0 0/])1e1&+i.1e2-1e1

NB.pe466 fixme
64([:#[:~.[:,*/&(>:@i.))1e16 NB. 1

NB.pe343 fixme
1&(((>:@[%(>:@[+.<:@]))$:(<:@]%(>:@[+.<:@])))`(%&])@.((]=<.)@%&]))^&3>:i.2e6 NB. fail to assign values, fail fail fail, i am failure, hear me whimper; extremely inefficient, out of memo for just the example

NB.pe022
+/(*>:@i.@#)([:+/(<:a.i.'A')-~a.&i.)&>/:~(<@}.@}:);._1',',1!:1 <'/tmp/p022_names.txt'

NB.pe092
+/(($:`(0:`1:@.(89=]))@.([:+./1 89=])[:+/*:@"."0@":)"0)>:i.1e7

NB.pe091 fixme
+/((]=<.)#])(([:%:[:*/-:@(+/)-0:,])"1)|:((>:,],:]),.(<:,],:]))(>:@i.@>.@%&3)1e9 NB. 1 outta memory and wrong
3 comb 51
   ((   (({.=(+/@}.))@:*:)#])@ \:~)"(1) 2 3 $ 3 4 5 3 4 6
      (((({.=(+/@}.))@:*:)#])@\:~)"(1) 3
(,.],.])i.51 NB. 2

NB.pe036
([:+/(#([:*./"1[:>(*/@(=|.)@":)&.>@((2&((([:>.[^.])#[)#:]);]))"0)))>:i.1e6

NB.pe127 fixme
([:|:[:(i.2)&{   (i.3)&(|."0 _))

>,..{(i.1.2e5);(i.1.2e5);(i.1.2e5)
"1

*./
[:+./"1
0&{<1&{
'q w e'=.
([:*/[:~.q:)

NB.pe847 fixme
NB. (2&+`1&+@.([:+./1&=))    "0
R=:".@#&'1'
h=:[:+/>.@-:@((<:@{.),}.)@\:~ NB. fixme
H=:{{
[:+/
for_q.>:i.y-2 do.end.
}}
{{for_q.>:i.y-2 do.for_w.>:i.y-1+q do.echo (+/,__,])q,w,(y-q+w) end.end.}} 5
{{a=.0 for_q.>:i.y-2 do.for_w.>:i.y-1+q do.a=.a+h q,w,(y-q+w) end.end.a}} 5

NB.pe025
>:(i.1e3"_)#@":"0{{(],[:+/(_1 _2)&{)^:(y-2)(1x&,^:2)''}}6e3

NB.pe049
    p:({.+i.@}.) p:^:_1(4 p:1e4),(_4 p:1e5)
NB. (( any cycle  )#])???

NB.pe074 fixme
([:+/!@"."0@":) @. (???)  (i.1e6),.1 NB. 1

NB.pe551
{{{:(],[:+/"."0@":)^:y 1x,''}}1e6 NB. 1
{:>@{:@{{($:@(<:&.>@{.,((],([:+/"."0@":))&.>@{:)))`]@.(1&=@>@{.)y}}M.(1e6-2);1 NB. 2 fixme
NB.pe413 fixme
{{w=.0 for_q.i.y do.w=.w+(([:(1=#)[:(#~(0=z|]))[:;[:"."1&.>[:([:(((-@i.@#@(#~((32{a.)~:]))@{.){]))[:|.(]\))&.>[:<"1(1&}.)^:(i.z=.#q))q=.":q)end.<:w}}1e19 NB. 1.1 too big an input, RIP RAM
{{'qq w'=.0 while.y>q=.qq=.>:qq do.w=.w+(([:(1=#)[:(#~(0=z|]))[:;[:"."1&.>[:([:(((-@i.@#@(#~((32{a.)~:]))@{.){]))[:|.(]\))&.>[:<"1(1&}.)^:(i.z=.#q))q=.":q)end.w}}1e7 NB. 1.2 constant space idem

NB.pe017 fixme annoying
{{
NB. teens                            (1[0-9])$
z=.0++/(10*3 6 6 8 8 7 7 9 8 8)
NB. multiples of ten                ([2-9])\d$
z=.z++/(10*10*6 6 5 5 7 6 6)
NB. terminal non-zero digit, hundreds ([1-9])$ ([1-9])\d\d$
z=.z++/(((1e2&*),([:1e2&*7&+))3 3 5 4 4 3 5 5 4)
NB. and
z=.z+(9*10*10-1)*3
NB. 1e3
z=.z+11
NB. missing 217..?
}}''


NB.pe345 fixme
{{
  'a r'=.0
  z=.{{
    if.1=#y do.
      r=:r,+/a,y
      a=:0
      return.
    end.
    for_q.i.#y do.
      for_w.i.#y do.
        r(a=:a,(<q,w){y)z(([:((<"0((#~w&~:)(i.#y)))&{&.|:)(<"0((#~q&~:)(i.#y)))&{)y)
      end.
    end.
    >./r
    r=:0
  }}

while.

>./r
}}".;._1(10{a.),2!:0'xclip -o'

NB.pe345
([:+/1=[:"."0[:":i.)
([:+/1=[:"."0[:":i.)

{{while. do.
end.
}}

NB.pe101
q=:1 _1 1 _1 1 _1 1 _1 1 _1 1
NB.    q p.1+i.11
NB. 1 683 44287 838861 8138021 51828151 247165843 954437177 3138105961 9090909091 23775972551

NB.pe180
(128 = 3!:0)
f[1,n](x,y,z) = x^n+1 + y^n+1 − z^n+1
f[2,n](x,y,z) = (xy + yz + zx)*(x^n-1 + y^n-1 − z^n-1)
f[3,n](x,y,z) = xyz*(x^n-2 + y^n-2 − z^n-2)

NB.pe180
   q: q % (+/ 1 1 4 4 4 4) NB. row, col, continued lr dia, tb lr inversion, rot?
127 3119

NB.pe047
{{while.do.if.([:*./4=[:#@~.@q:0 1 2 3+])y do.break.else.y=.y+1 end.end.}}2

NB.pe048
10e10|+/^~x:1+i.1e3

NB.pe049
NB.    (#~(4=[:#[:~.[:"."0":)"0) @ ([: p: [: i. [: (-/ - {:)  p:^:_1) (_4 p:1e4),(4 p:1e3)
NB.    q=:(-/]) 1487 4817 8147 8889
NB.    ([: +/"1  (="1 0 ~.) ) ,q

NB.    ( (2=([: +/"1  (="1 0 ~.) ) ) # ~.) ,q
NB. ( (2=([: +/"1  (="1 0 ~.) ) ) # ~.) , (-/]) (#~(4=[:#[:~.[:"."0":)"0) @ ([: p: [: i. [: (-/ - {:)  p:^:_1) (_4 p:1e4),(4 p:1e3)
{{
for_q.</.|. (-/]) ([: p: [: ( ([:i.-/) + {:) p:^:_1) (_4 p:1e4),(4 p:1e3) do.
>q
    ([: (([:i.-/)+{:) p:^:_1) (_4 p:1e4),(4 p:1e3)
echo q
end.
}}''
(#~a:&~:)( (2=([: +/"1  (="1 0 ~.) ) ) # ~.) &. > </.|. (-/]) (#~(4=[:#[:~.[:"."0":)"0) @ ([: p: [: ( ([:i.-/) + {:) p:^:_1) (_4 p:1e4),(4 p:1e3)
(#~a:&~:)( (#~ 2&=) ([: +/(=/])))  (-/]) (#~(4=[:#[:~.[:"."0":)"0) @ ([: p: [: ( ([:i.-/) + {:) p:^:_1) (_4 p:1e4),(4 p:1e3)
(#~ ( (3 = [: +/"1 [: , ="0 1)"1))  (-/]) (#~(4=[:#[:~.[:"."0":)"0) @ ([: p: [: ( ([:i.-/) + {:) p:^:_1) (_4 p:1e4),(4 p:1e3)
(#~ ( (3 = [: +/"1 [: , ="0 1)"1))  |: (-/]) (#~(4=[:#[:~.[:"."0":)"0) @ ([: p: [: ( ([:i.-/) + {:) p:^:_1) (_4 p:1e4),(4 p:1e3)
(#~ (3=[:+/(=/])))  (-/]) (#~(4=[:#[:~.[:"."0":)"0) @ ([: p: [: ( ([:i.-/) + {:) p:^:_1) (_4 p:1e4),(4 p:1e3)

( [: (#~ (2 = [: +/ (=/ ])))"1 (| (-/ ]) [: (#~ (4 = [: # [: ~. [: "."0 ":)"0) [: p: [: (([: i. -/) + {:) p:^:_1) ) (_4 p:1e4),4 p:1e3
(#~ (2=[:+/(=/])))"1 | (-/]) ([: (#~(4=[:#[:~.[:"."0":)"0) [: ] [: ] ])   1487 1123 2231 44444 5798 4817 8147

( [: (#~ (    (2 = [: +/ (=/ ]))"1 @ (| (-/ ]))    )) ( [: (#~ (4 = [: # [: ~. [: "."0 ":)"0) [: p: [: (([: i. -/) + {:) p:^:_1) ) (_4 p:1e4),4 p:1e3
(#~(2 <: [: +/ 2 = [: +/ (=/ ]))"1)  > {:  ( [: {{ ({~(-@#@$)<\#@$#i.@#)"(#$y) ( (_1&|.) ^: (i.@#) y) }} (| (-/ ])) ) &. > qq,<1487 4817 8147 9

{{Y=.''
for_q.w=.([: (#~ (4 = [: # [: ~. [: "."0 ":)"0) [: p: [: (([: i. -/) + {:) p:^:_1)(_4 p:1e4),4 p:1e3 do.
Y=.Y , <  ( (#~ ([: *./"1 (":q) e. ":)"0)) w NB. /:~
end.
Y=.~.Y
NB. for_q.<;._1 Y do.
NB.  NB. echo (#~ (    (2 = [: +/ (=/ ]))"1 @ (| (-/ ]))    ))  >q
NB. echo (#~(2 <: [: +/ 2 = [: +/ (=/ ]))"1)  > {:  ( [: {{ ({~(-@#@$)<\#@$#i.@#)"(#$y) ( (_1&|.) ^: (i.@#) y) }} (| (-/ ])) ) &. > q
NB. end.
for_q.~.Y do.
 NB. echo (#~ (    (2 = [: +/ (=/ ]))"1 @ (| (-/ ]))    ))  >q
NB. echo (#~(2 <: [: +/ 2 = [: +/ (=/ ]))"1)  > {:  ( [: {{ ({~(-@#@$)<\#@$#i.@#)"(#$y) ( (_1&|.) ^: (i.@#) y) }} (| (-/ ])) ) &. > q
echo (#~(2 <: [: +/ 2 = [: +/ (=/ ]))"1)  > {:  ( [: {{ ({~(-@#@$)<\#@$#i.@#)"(#$y) ( (_1&|.) ^: (i.@#) y) }} (| (-/ ])) ) &. > q
end.
,.Y
}}''

   ] zz=: ,. (#~ a: & ~: )    ,             (#~ (3 <: #))&.> NB.z=.{{...}}

([:     {{+./,(({.~([: I. 0&=))y)="0 1|(}.~(1 + [: I. 0&=))y}}"1    (-/]) ) 0 10 20 25 200
0 10 20 30 40

NB.pe149 fixme
{{>./>{."1\:~(0&>:+/;._2])&.>"0(</.,([:</.|.),([:<"1|:),<"1)y}}q NB. 3580522
{{>./;+/L:0(0&<]/;.2])&.>(#~(1<#@>))(</.,([:</.|.),([:<"1|:),<"1)y}}q NB. 277570854
{{([:>./[:;^:2[:([:(0&=([:<+/);._2])(0($#:[:I.0>])@]}]))L:0(</.,([:</.|.),([:<"1|:),<"1))y}}q NB. 6029868
{{([:>./[:;^:2[:(0&=([:<+/);._2])L:0(</.,([:</.|.),([:<"1|:),<"1))y}}q NB. 6029868
{{([:>./[:+/S:0[:(0&>:<;._1])L:0(</.,([:</.|.),([:<"1|:),<"1))y}}8 8$,q NB. 277570854
{{([:>./[:;[:([:+/S:0[:(0&>:<;._1])(*0&<))L:0(</.,([:</.|.),([:<"1|:),<"1))y}}q NB. 6029868
{{([:>./[:;[:([:+/"1([:>'0'&chopstring)&.":&(*(0&<))) L:0 (</.,([:</.|.),([:<"1|:),<"1))y}}q NB. 3690479
{{([:>./[:;[:([:+/S:0[:(((2</\(([:|.1+i.@#)*(0&<))),{:)<;._1])(*0&<))L:0(</.,([:</.|.),([:<"1|:),<"1))y}}q NB. 6029868
{{([:>./[:;[:([:+/S:0((_1|.((2</\]),{:))@(0&<))<;.1(*0&<)) L:0 (</.,([:</.|.),([:<"1|:),<"1))y}}q NB. 6029868

q=.(2#2e3)$,(s=.{{if.56>y do.(5e5-~1e6|100003 _200003 0 300007 p.])y else.5e5-~1e6|1e6+(s y-24)+s y-55 end.}}"0 M.)1+i.2e3^2

52852124
^
277570854
48519449
6029868
5903977
5918647

NB.pe051
{{
for_digitNumber.2+i.8 do.
primes=.([:":[:,.[:p:[:({:+([:i.-/))((_1 p:10^>:),(_1 p:10^])))digitNumber
for_subtitutedDigitNumber.>:i.digitNumber-1 do.
for_constantDigitPattern.subtitutedDigitNumber{{q=.((w=.y-x)$<i.0 0),<i.1 0 for.i.x do.q=.(i.>:w),.&.>,&.>/\.>:&.>q end.;q}}1+digitNumber do.
substitutionPattern=.((i.1+digitNumber)(([:-.e.)#[)constantDigitPattern)
for_prime.primes do.
if.8=#z=.(#~1&p:)".('0123456789'substitutionPattern}])&.|:(10,(1+digitNumber))$,prime do.<./z return. end.
end.
end.
end.
end.
}}0

NB.pe309 fixme
{{
for_y.1+i.y do. NB.x
for_x.1+y+i.y-y do. NB.y
w=.-:(y*1&o.z)+(x*1&o.0.5p1-z)
w=. (0.5^~[:-/2^~])

h=(1&o.z)=(1&o.0.5p1-z)
(1 o.(,-&0.5p1))z

x*(?)

end.end.
}}2e2

NB.pe183 fixme
+/ (-`]@.([:  (2&x:([:+./~:)2 x:!.0])  [:>./[:([:*/[#]%[)/"1(,.~(1+i.)))"0)  5+i.1+1e4-5 NB. _49995838 very wrong, also wrong for 5⸺1e2
NB. +/ (-`]@.([:  (2&x:([:*./~:!.0)2 x:!.0])  [:>./[:([:*/[#]%[)/"1(,.~(1+i.)))"0) 5+i.1+1e2-5 NB. same
NB. +/ (]`-@.([:  (2&x:([:+./~:)2 x:!.0])  [:>./[:([:*/[#]%[)/"1(,.~(1+i.)))"0) 5+i.1+1e4-5x NB. nope
NB. (+/!.0) (-`]@.([:  (2&x:([:*./~:!.0)2 x:!.0])  [:>./[:([:*/[#]%[)/"1(,.~(1+i.)))"0) 5+i.1+1e2-5 NB. nope
NB. (+/!.0) (-`]@.([:  (2&x:([:*./~:!.0)2 x:!.0])  [:>./[:([:*/[#]%[)/"1(,.~(1+i.)))"0) 5+i.1+1e2-5x NB. nope
NB. (+/) (-`]@. (  ([:  ( (2 x:!.0])([:*./=)(2&x:)  )  [:>./[:([:*/[#]%[)/"1(,.~(1+i.)))"0) ) 5+i.1+100-5x NB. nope

NB.pe182 fixme
$ (#~ (1=+.&f)) (1+[:i.-&2) f=.*/<:'p q'=.19 37

NB.pe096 fixme
(9 9)&$"1 ;"1 ((10*i.50)+"(0 1)1+i.9) { <;._1 LF, 1!:1<'/tmp/p096_sudoku.txt' NB. my solver sucks ass

NB.pe099
($#:[:I.[:(>./=]),)([:x:[:({:*([:^.{.))".);._1 LF,1!:1<'/tmp/0099_base_exp.txt'

NB.pe113 fixme
+/((([:*./2<:/\])~:([:*./2>:/\]))([:"."0":))"(0)i.1e6 NB. 12897
+/,(((([:*./2<:/\])~:([:*./2>:/\]))([:"."0":)),(1=[:#[:~.":))"(0)i.1e6-1 NB. 12951
+/,(((([:*./2<:/\])~:([:*./2>:/\]))([:"."0":)),(1=[:#[:~.":))"(0)i.1e100-1 NB. head death of the universe?
{{'q w'=.0 while.y>q=.1+q do.w=.w++/(((([:*./2<:/\])~:([:*./2>:/\]))([:"."0":)),(1=[:#[:~.":))q end.w}}1e6 NB. 12951

NB.pe061 fixme
p3=.(-:*>:)
p4=.(*~)
p5=.(-:*(1-~3&*))
p6=.(*(1-~2&*))
p7=.(-:*(3-~5&*))
p8=.(*(2-~3&*))
P3=.(#~(1e3&<:*.9999&>:))p3>:i.1e3
P4=.(#~(1e3&<:*.9999&>:))p4>:i.1e3
P5=.(#~(1e3&<:*.9999&>:))p5>:i.1e3
P6=.(#~(1e3&<:*.9999&>:))p6>:i.1e3
P7=.(#~(1e3&<:*.9999&>:))p7>:i.1e3
P8=.(#~(1e3&<:*.9999&>:))p8>:i.1e3
c=.((2 3{[)-:0 1{])&":
{{
r=.0
for_q.(([:i.[:!#)A.([:i.#)C.])P3;P4;P5;P6;P7;P8 do.
  for_w.>
end.
}}

NB.pe062 fixme
5{{while.y=.y+1 do.
if.x=#q=.(#~(0=1|]))~.(i.@!@#A.i.@#C.])&.([:":^&3)y do.^&3<./q return.end.
echo q
NB. if.x=#q=.(#~(<.=>.))~.(i.@!@#A.i.@#C.])&.([:":^&3)y do.q return.end.
end.}}4000x

{{while.echo 5~:#q=.(#~(<.=>.))~.(i.@!@#A.i.@#C.])&.([:":^&3)y=.y+1 do.end.^&3<./q}}1x

NB.pe282 fixme
(14^8)|+/{{if.0=x do.y+1 elseif.(0<x)*.0=y do.(<:x)$:1 elseif.(0<x)*.0<y do.(<:x)$:(x$:<:y)end.}}M./"1(,.~)i.7
q=.{{if.0=x do.y+1 elseif.(0<x)*.0=y do.(<:x)q 1 elseif.(0<x)*.0<y do.(<:x)q(x q<:y)end.}}M.
(14^8)|+/q/"1(,.~)i.7

NB. THE WEEKLY CHALLENGE
NB.wc0011
(]`('E'[[)@.('e'&=)"0)'Perl Weekly Challenge' NB. 1
(]`('E'"_)@.('e'&=)"0)'Perl Weekly Challenge' NB. 2
(]`(-&32)@.(101&=))&.(a.&i.)'Perl Weekly Challenge' NB. 3

NB.wc0012
((":`f`b`((f=:'fizz'"_),b=:'buzz'"_))@.(#.@(0=3 5&|~))"0)>:i.15

NB.wc0021 FIXME tooooo complicated, edge cases, yikes.
f=.{{
".NB. trivial, does most both positive and negative, but it doesn't explicitly say that's unwanted
{{  (])`(+:&.".)@.(0&<@".)"(0) &. > (a:&~:#])<;._1' ',y}}  '_001   002  3 4 _5' NB. 1.2 assuming, 1, string arguments since J doesn't do leading zeros, 2, space delimited numbers, 3, reals allowed
]`?@.('_'&=)
   (#~'_'&~:)
{{( (#~(#y)~:]) @ i.&('._123456789')) <;._1 ' ',y}}  '_001   002  3 4 _5'...?
NB. tooooo complicated, edge cases, yikes. FIXME

NB.wc0022
(+/\])

NB.wc2382 fuck me, this was more annoying than 148.1
{{if.0<#a=.~.(#~-.@~:)o=.(#*({{{:`([:$:([:*/"."0@":@{.),>:@{:)@.(9&<@{.)"1 y}}@|:@,:0:))y do.for_s.a do.o=.((+/:d&{)(d=.s I.@:-.@i.o)}])o end.end.y=.|.(\:o){y}}

NB.wc2141
((((('G';'S';'B')"_(i.3){]),(":&.>@((-&4@#-i.@-&3@#){])))@(/:~;/))/:\:) NB. 1
(((((<"0'GSB')"_(i.3){]),(":&.>@((-&4@#-i.@-&3@#){])))@(/:~;/))/:\:) NB. 2

NB.wc2142
(#~(],{:)@:-.@(2((=)+.(=<:))/\])) NB. 1 fixme

NB.wc2151
([:+/-.@([:*./2</\/:)@>)'abc';'xyz';'tsu'

NB.wc2152 fixme

NB.wc2351
(1=[:+/0=2</\])

NB.wc2352
(#$([:;[:(]`(,])@.(0&=))&.>;/)) NB. 1
(#$([:;(]`(,])@.(0&=)))) NB. 2 fixme
(#$([:,([:;(]`(,])@.(0&=)))"0)) NB. 3
(#$(([:>:0&=)#])) NB. 4
(#$(#~[:>:0&=)) NB. 5

NB.wc1481
(#~((,/@([:*./"(1)_3((e.&2 4 6@{.),(1:`(e.&0 3 4 5 6@{~&1)@.(1:<#)),(1:`(e.&0@{~&2)@.(2:<#)))\])"."0@|.@":))"(0))i.1e2

NB.wc1482 fixme

NB.wc2381 fixme

NB.wc1971
((#~0&~:),([:+/0&=)#0:`(''"_)@.(#=i:&0))

NB.wc1972
((/:~@]`(\:~@])@.[)~(1:,(2(</)`(>/)\])))

NB.wc2391
(-:&;) NB. assuming 2 lists of boxed strings

NB.wc2392
((#~a:&~:)@:((#~([:*./'ALLOWED'e.~]))&.>))NB. 1 assuming list of boxed strings
'ALLOWED'((a:&~:#])@:((([:+./[e.~])#])&.>))NB. 2 assuming list of boxed strings

NB.wc2361
0 0 0(((1 0 0+[)$:}.@])`(0:`((_1 1 0+[)$:}.@])@.(0<[:{.[))`(0:`((_3 0 1+[)$:}.@])`((_1 _1 1+[)$:}.@])@.((3<[:{.[)+.(2*[:*./0<0 1{[)))@.([:,[:>:[:I.5 10 20&=@])"_ _ 0)5 5 10 10 20 NB. 1 fuck me, this is annoying fixme
0 0 0(_1:`_2:`(((_3 0 1+[)$:}.@])@.((3<[:{.[)+.(2*[:*./0<0 1{[)))@.([:,[:>:[:I.5 10 20&=@])"_ 0)5 5 10 10 20 NB. 1 fuck me, this is annoying to get tacit fix
0 0 0{{ NB. 2 FUCK ME, this was annoying
for_q.y do.
  select.q
  case.5 do.
    x=.1 0 0+x
  case.10 do.
    if.(0<0&{)x do.
    x=._1 1 0+x
    else.0 return.
    end.
  case.20 do.
    if.(2<0&{)x do.
    x=._3 0 1+x
    elseif.([:*./0<0 1&{)x do.
    x=._1 _1 1+x
  end.
end.
1
}}5 5 10 10 20

NB.wc2362

NB.wc2371
[:>./[:+/"1]<"1 1i.@!@#A.i.@#C.]

NB.wc2372 this is retarded
fixme fixme fixme fixme
{{'Q W E R'=.y NB. 1 year month weekdayOccurance weekday
assert.*./(7 5 12>:R,E,W),((0<]),([:(<.=>.)Q,])W,E,R) NB. (positive) integer; also, yes, fuck you, exit disgracefully
d=.(Q-1970)*365.2425+(W-1)*30.436875 NB. exact days to the first of desired month with unix epoch as reference
while.0<d do.
?????????????????????
31  1 3 5 7 8 10 12=
30  4 6 9 11
29  2 *. 1=[:4|y
28  2
D=.
R=([:7&|[:<.5-~365.2425 12 30.436875&#.)Q,W,D
}}

NB.wc2401
'abc'((-:&:(0&(3!:12)))>@({.&.>@]))'ABC';'BCD';'CDE'

NB.wc2402
{~

NB.wc2411
NB. 1 this is going to be very explicit and annoying
{{for_q.y
({:@<;._1@q&,)
3<#
NB. 2
NB. NB. (3}.({.-~}.\))
NB. NB.     (   (3-~#)<\]) i:4
NB. (_3}.(}.^:(>:@i.@#)))i.10
NB. ([:,[:,.(i.@#)([:<}.)"0 _])i.10
NB. (_3}. [: (({.-~}.)&.>) [:,[:,.(i.@#) ([:<}.)"0 _])i.10
NB. ({.-~}.\) &. >   ??
NB. (     _3}.[:(({.-~}.)&.>)[:,[:,.(i.@#)([:<}.)"0 _]) q
NB. ([: ( ({.-~}.) &.>)  _3}.[:(({.-~}.)&.>)  [:,[:,.(i.@#) ([:<}.)"0 _]) q
NB. (     _3}.[:(({.-~}.)&.>)  [:,[:,.(i.@#) ([:<}.)"0 _]) q
NB. ([: (,:({.-~}.)&.>) _3}.[:(({.-~}.)&.>)  [:,[:,.(i.@#) ([:<}.)"0 _]) q
NB. ([: (,:q) _3}.[:(q=:({.-~}.)&.>)  [:,[:,.(i.@#) ([:<}.)"0 _]) 0 1 4 6 7 8
NB. ([:({.-~}.)&.>  [:,[:,.(i.@#) ([:<}.)"0 _]) 0 1 4 6 7 8
NB.    >(  _3}.[:(({.-~}.)&.>)  [:,[:,.(i.@#) ([:<}.)"0 _]) q
NB.          ([: (,:({.-~}.)&.>)  _3}.[:(({.-~}.)&.>)  [:,[:,.(i.@#)([:<}.)"0 _])   /:~ 0 10 20 15 3
NB. ;"1
NB.    (     _3}.[:(({.-~}.)&.>)          [:,[:,.(i.@#)([:<}.)"0 _]) /:~ 0 10 20 15 3
NB. {{
NB. q=.([:;"1[:,._3}.[:(({.-~}.)&.>)[:,[:,.(i.@#)([:<}.)"0 _])y
NB.    ( [:  ($#:[:(i.=&1),)          (="1 0*&2) )  _1 3 10 15 20
NB. }} /:~ 0 10 20 15 3
NB. (([:i.3-~#){])+
q ([:;"1[:,._3}.[:(({.-~}.)&.>)[:,.(i.@#)([:<}.)"0 _])
q"1 ([:;"1[:,._3}.[:(({.-~}.)&.>)[:,.(i.@#)([:<}.)"0 _])
({~([:(#~([:(*./"1)1</]))[:($#:[:(i.=&1),)(="1 0*&2)))
({~([:(#~([:*./"(1)1</]))[:($#:[:(i.=&1),)(="1 0*&2)))
( ( ([:~.[:(#~([:(+./"1)1</]))[:($#:[:(i.=&1),)(="1 0*&2)))  ([:;"1[:,._3}.[:(({.-~}.)&.>)[:,.(i.@#)([:<}.)"0 _]) )w
({~((([:,[:~.[:(#~([:(+./"1)1</]))[:($#:[:(i.=&1),)(="1 0*&2)))([:;"1[:,._3}.[:(({.-~}.)&.>)[:,.(i.@#)([:<}.)"0 _])))
({~(((2+[:~.[:(#~([:+./"(1)0</]))[:($#:[:(i.=&1),)(="1 0*&2)))([:;"1[:,._3}.[:(({.-~}.)&.>)[:,.(i.@#)([:<}.)"0 _])))w
(I.([:+./"(1)0<]))c
(  ([:([:($#:[:(i.=&1),)(="0 1*&2)))([:;"1[:,._3}.[:(({.-~}.)&.>)[:,.(i.@#)([:<}.)"0 _]))w
( [:  (([:($#:[:(i.=&1),)(="0 1*&2)))       ([:;"1[:,._3}.[:(({.-~}.)&.>)[:,.(i.@#)([:<}.)"0 _])) 0
( [:  (([:($#:[:(1 i.~]),)(="0 1*&2)))       ([:;"1[:,._3}.[:(({.-~}.)&.>)[:,.(i.@#)([:<}.)"0 _])) 0
( [:($#:[:(#~0~:])[:(i.@#*1&E.),)  (="0 1*&2)  ([:;"1[:,._3}.[:(({.-~}.)&.>)[:,.(i.@#)([:<}.)"0 _])  )0 1 4 6 7 10
([:($#:[:(#~0~:])[:(i.@$*1&E.),)  (="0 1*&2)  ([:;"1[:,._3}.[:(({.-~}.)&.>)[:,.(i.@#)([:<}.)"0 _])  )0 1 4 6 7 10
([:($#:[:(#~0~:])[:(i.@$*1&E.),) [:(="0 1*&2) ([:;"1[:,.[:(({.-~}.)&.>)_3}.[:,.(i.@#)([:<}.)"0 _]) )0 1 4 6 7 10
{{
NB. for_q.([:,:(i.@#)([:<}.)"0 _])y do.
for_q.(([:;"1[:,.[:(({.-~}.)&.>)_3}.[:,.(i.@#)([:<}.)"0 _]))y do.
}}0 1 4 6 7 10

NB.wc2412
(/:#@q:)

NB.wc2421
((([:I.[:-.[e.]){[),:(([:I.[:-.]e.[){]))

NB.wc2422
([:-.|."1)

NB.wc2431
([:+/[:+/[:}:[:|:[:(],.(i.@#))+:<"0 1]) NB. 1 close, but too fiddly fixme
([:+/[:+/[:;((((+:@{.)<"0 1(}.))&.><\.)&.|.)) NB. 2

NB.wc2432
([:+/[:([:+/[:<.{.%}.)"1[:(],.{.@|:)[:~.(/:/:)"1@(((i.3){])&.|:)@(i.@!@#A.i.@#C.])) NB. fixme totes not annoying; also, doesn't work on 7#7 because of ~.

NB.wc0031
((i.5){(#~([:*./"1[:5&>:q:)))

NB.wc0032
(i.!/i.)

NB.wc0041
0j9":1p1

NB.wc0042
TableOfEqualLengthWords(([:+./"1 e.)#[)ListOfLetters
(#~([:+./e.&ListOfLetters)@>)ListOfBoxedStrings

NB.wc0051
NB. how about no

NB.wc0052
{{w=.0 for_q.y do.w=.w,(([:+/[:;([:+./e.&(>q))&.>)y)end.({.\:}.w){y}}ListOfBoxedStrings

NB.wc0061 totally not annoying
([:>[:([,',',])&.>/ [:((":@{.,',',":@{:)`":@.(1=#)`(":@{.,'-',":@{:)@.(2<#))&.>(([:-.0,(2(>:@[=])/\]))<;.1]))

NB.wc0062 fixme precision loss on last 3
32j0":^(1p1*%:163)

NB.wc0071
(#~(0=([:+/[:"."0":)|])"0)i.51

NB.wc0072

NB.wc0081
(i.5){(#~(=([:+/[:}:[:}.[:I.[:(=<.)(%i.@>:))"0))>:i.1e5 NB. brute forcing it is real fucking slow... fixme

NB.wc0082
{{(],~(' '#~([:<.2%~((>./#@>y)-#))))@>y}}ListOfBoxedStrings

NB.wc0091
{.(#~(5<:#@~.@":"0@*:))101+i.1e2 NB. yes, i gave up on trains, don't bully me

NB.wc0092
NB. what?

NB.wc0101
enc=:{{NB. 1 retarded roman numerals get the retard treatment, also, yes, least lines because legibility is for wimps
'e r'=.(#q=."."0":y);''
for_w.|.@i.e do.select.w case.3 do.r=.r,(((e-w+1){q)#'M')case.2 do.if.4>((e-w+1){q) do.r=.r,(((e-w+1){q)#'C')elseif.4=((e-w+1){q) do.r=.r,'CD'elseif.9>((e-w+1){q) do.r=.r,'D',((((e-w+1){q)-5)#'C')elseif.9=((e-w+1){q) do.r=.r,'CM'end.case.1 do.if.4>((e-w+1){q) do.r=.r,(((e-w+1){q)#'X')elseif.4=((e-w+1){q) do.r=.r,'XL'elseif.9>((e-w+1){q) do.r=.r,'L',((((e-w+1){q)-5)#'X')elseif.9=((e-w+1){q) do.r=.r,'XC'end.case.0 do.if.4>((e-w+1){q)do.r=.r,(((e-w+1){q)#'I')elseif.4=((e-w+1){q)do.r=.r,'IV'elseif.9>((e-w+1){q)do.r=.r,'V',((((e-w+1){q)-5)#'I')elseif.9=((e-w+1){q)do.r=.r,'IX'end.end.end.r}}"0
enc=:{{NB. 2 ever so slightly less retarded
f=.{{if.4>m do.y=.y,(m#(0{x))elseif.4=m do.y=.y,(1 0{x)elseif.9>m do.y=.y,(1{x),((m-5)#(0{x))elseif.9=m do.y=.y,(0 2{x)end.}}
for_w.|.@i.e do.select.w case.3 do.r=.r,(((e-w+1){q)#'M')case.2 do.r=.'CDM'((e-w+1){q)f r case.1 do.r=.'XLC'((e-w+1){q)f r case.0 do.r=.'IVX'((e-w+1){q)f r end.end.r}}"0
NB. sadly, enc^:_1 does not work, so we give it the good ol' explicitaroo
dec=:{{(+/'I'E.y)+(1e1*+/'X'E.y)+(1e2*+/'C'E.y)+(1e3*+/'M'E.y)+(0:`_1:@.([:+./'IV'E.])y)+(0:`_1:@.([:+./'IX'E.])y)+(5e0*+/'V'E.y)+(5e1*+/'L'E.y)+(5e2*+/'D'E.y)+(0:`(_10"_)@.([:+./'XL'E.])y)+(0:`(_10"_)@.([:+./'XC'E.])y)+(0:`(_100"_)@.([:+./'CM'E.])y)+(0:`(_100"_)@.([:+./'CD'E.])y=.y,'  ')}}"1 NB. no fail on single roman digit or null

NB.wc0102 fixme fuck this so much
js=:{{
if.0=M=.x([:+/[:,((((#~0<:])i:x(([:<:[:<.[:-:[>.])&#)y)+"1 0 i.@#@[){[) ="1 0[)y do.0 return.end. NB. fixme gives false positives
'q1 q2'=:'FAREMVIEL';'FARMVILLE'
'FAREMVIEL'{{x(   ((((#~0<:])i:x(([:<:[:<.[:-:[>.])&#)y)+"1 0 i.@#@[) )  )y}}'FARMVILLE'
q1{{x(  ([:(#~(0<:])*.#>])&.>[:<"1((([:i:[:<:[:<.[:-:>.)&#)+"1 0 i.@#@[)){[  )y}}q2
q1{{x(  <"0@([:(#~(0<:])*.#>])&.>[:<"1((([:i:[:<:[:<.[:-:>.)&#)+"1 0 i.@#@[)){[  )y}}q2
q1{{
q=.x(  (<"0@([:(#~(0<:])*.(#x)>])&.>[:<"1((([:i:[:<:[:<.[:-:>.)&#)+"1 0 i.@#@[)){[)="1 0]  )y
'M T'=.(([:+/[:,[:>./[:>[:</.|:)q3);(+/,q3)
q2
????????????????????
3%~+/   (#x)+(#y)+(-&T%*:,)
 NB.    (  _(([:-#@$)<\#@$#i.@#)}] )i.3 3
 NB. (_(([:-[:#$)<\#@$#i.@#)}])i.3 3
NB. (=/]) * q
   (q1=/q2)
([:-.[:(=/])[:i.#)q1
   (([:-.[:(=/])[:i.#)q1) * (q1 =/ q2)
}} NB. 1
{{((M%#x)+(M%#y)+(M-(t=:(+/xm~:&(M&{.)ym)%2))%(M=:(xm=.(+./"1 e)#x)<.&#(ym=.(+./"2 (e=.(x=/y)*(((x>.&#y)%2)-1)>:|x-/&(i.@#)y))#y)))%3}} NB. 2 stolen from rosetta :3

NB.wc0111
(_32-5*32%9)%((9%5)-5%9) NB. 1 arithmetic, more paper than computation
>@{.@p.0,(_32*(1+5%9)*45%56) NB. 2.1 same, but use the roots primitive
>@{:@p.(32*1+5%9),((-/%)9%5) NB. 2.2

NB.wc0112
([:(=/])i.) NB. 1
{{x(1(x(|:@(([,])$i.@]))y)}([$])$0:)y}} NB. 2 x-dim y-len identity array

NB.wc0121
{.(#~([:0&p:]))([:>:[:*/[:p:i.)"(0)i.10

NB.wc0122
([:([:;'/',~&.>([:*./"(1)2=/\"1])#([:{.|:))([:|:[:/:~[:;"1[:([:<;._1'/',])&.>,.))ListOfBoxedStrings

NB.wc2441
([:+/[:;[:(([:*:>./)*<./)"1&.>([:<"1[:(>:@i.([#:(-:(i.~~.))@#:#])i.@!)[:#>)]/.&.><)

NB.wc2442
([:+/"1]>/])

NB.wc0131 fixme
NB. nope

NB.wc0132
F=:((]-(M@F@<:))`1:@.(0=]))"(0)M.
M=:((]-(F@M@<:))`0:@.(0=]))"(0)M.

NB.wc0141 fixme
NB. retarded definition

NB.wc0142 fixme

NB.wc0151
((i.10){]#~(p:<(2%~(p:@<:+p:@>:)))"(0))>:i.1e2
((i.10){]#~(p:>(2%~(p:@<:+p:@>:)))"(0))>:i.1e2

NB.wc0152
(($msg)$key)(a.{~[:+/"1[:|:97 0-~,:&(a.i.0&(3!:12)))msg

NB.wc0161
(i.(>./));(([:*/[:-.}:)*{:)&.>([:<\1e2%~])>:i.1e2

NB.wc0162 fixme
{{
assert.(('1'=0&{)+.('3'=0&{)+.('bc1'=(i.3)&{))y
assert.-.+./'OIl0'e.y
assert.((3(128!:6)])^:2((i.19){((i.25)&{)&.|.y))=((->:i.4){y) NB. 100 or 160 hash? also, bytes nots characters
assert.25<:$y
}}

NB.wc2451
ListOfNumbers(<:@[{])ListOfBoxedStrings

NB.wc2452
([:>./[:,[:;[:([:".[:(#~' '&~:)":)"1&.>([:(#~(0=3|+/))"1 i.@!@#A.i.@#C.])&.>@(#:@i.@(2&^)@#<@#"1 _]))

NB.wc2461
?6#49

NB.wc2462
([:*./[:(<.=>.)(([:%.2]\]{~([:i.2-~#))+/ .*(3}.])))

NB.wc2001
0:`([:*./[:=/"(1)3(2-/\])\])@.(2<#)

NB.wc2002
q0=:0 :0

| |
| |
| |

)
q1=:0 :0
  |
  |
  |
  |
  |
)
q2=:0 :0

  |

|  

)
q3=:0 :0

  |
--|
  |

)
q4=:0 :0
| |
| |
--|
  |
  |
)
q5=:0 :0

|  

  |

)
q6=:0 :0

|  
|--
| |

)
q7=:0 :0

  |
  |
  |
  |
)
q8=:0 :0

| |
|-|
| |

)
q9=:0 :0

| |
--|
  |

)
'q0 q1 q2 q3 q4 q5 q6 q7 q8 q9 '=:(5 3$(#~((10{a.)&~:)))&.>(q0;q1;q2;q3;q4;q5;q6;q7;q8;q9)
<"2((q0"_)`(q1"_)`(q2"_)`(q3"_)`(q4"_)`(q5"_)`(q6"_)`(q7"_)`(q8"_)`(q9"_)@."."0":)200

NB.wc2011
(([:i.1+#)#~([:-.]e.~([:i.1+#)))

NB.wc2012
#@;@(>:@i.,.&.>((<@;@(((-<.])#)(>:@i.@[([,.(>:{."1)#])&.>{.)]),])^:(<:@[(>.)0:)<@,:@i.@0:))

NB.wc2021
([:+./3*./\(2|]))

NB.wc2022 annoying much?
{{((''$I.+./"1 e E.q)+>:i.#(e=.>{./:~w=.(]<;.2~[:(*./"1)1 0="1 1])q=.{{]`(1 1 q}])@.(0<#q=.([:I.[:+./"(1)1 1&E."1 1)y)y}}(2(<,>:)/\])y)){(,{:)y}} NB. fixme doesn't capture whole valley due to cutting

NB.wc2031
([:+/[:(([:+/}:)={:)"1[:,"(2)4({~4{{q=.((d=.y-x)$<i.0 0),<i.1 0 for.i.x do.q=.(i.>:d),.&.>,&.>/\.>:&.>q end.;q}}#)\]) NB. 1 fail
([:,"(2)4{{((4{{q=.((d=.y-x)$<i.0 0),<i.1 0 for.i.x do.q=.(i.>:d),.&.>,&.>/\.>:&.>q end.;q}}#){])y}}   \])  i.8 NB. 2 fail
([:+/[:;[:([:(([:+/}:)={:)"1({~(4 {{q=.((d=.y-x)$<i.0 0),<i.1 0 for.i.x do.q=.(i.>:d),.&.>,&.>/\.>:&.>q end.;q}}#)))&.>([:(#~a:&~:)[:,[:~."1(3)&}.&.|.<\.])) NB. 3

NB.wc2032
NB. nope

NB.wc2041
([:*./2<:/\])

NB.wc2042
(r,c)$]

NB.wc2051
(([:<:3<.#){\:~)

NB.wc2052
([:>./[:22 b./"1 ~.{~(2{{q=.((d=.y-x)$<i.0 0),<i.1 0 for.i.x do.q=.(i.>:d),.&.>,&.>/\.>:&.>q end.;q}}#))

NB.wc2061
([:<./(12*60)|[:-/"1[:({~2{{q=.((d=.y-x)$<i.0 0),<i.1 0 for.i.x do.q=.(i.>:d),.&.>,&.>/\.>:&.>q end.;q}}#)[:;(24 60#.[:".' '2}])&.>)ListOfBoxedStrings

NB.wc2062
([:>./[:,[:(([:<./(i.2)&{)+([:<./(2+i.2)&{))"1(i.@!@#A.i.@#C.]))

NB.wc2071
(#~((1=[:+/[:+./"1('qwertyuiop','asdfghjkl',:'zxcvbnm')e.])@(0&(3!:12))@>))ListOfBoxedStrings

NB.wc2072
([:>./(#~(>:~([:+/"1(<:/])))))

NB.wc2081 Fucking state, ffs. What a bane.
ListOfBoxedStrings{{w=.i.0 2 for_q.x(([:I.[e.]){])y do.w=.w,((q i.~y)+(q i.~x));q end.{:|:(#~[:(={.)[:({.&.|:)/:~)w}}ListOfBoxedStrings

NB.wc2082
(([:I.[:-.~:),((~:~({.+i.@#))#({.+i.@#)))

NB.wc2472
2&{{((''$((0{$#:[:I.[:(=~>./)[:,[:+/[:(=/])x<\])y))+i.x){y}}

NB.wc2482
((2 2$1 1 2 2)([:+/,);._3])

NB.wc2481
([:<./[:|([:I.=)-"0 1 i.@#@])

NB.wc2491
{{assert.(([:*./0=2|[:+/"1~.=/]),(0=2|#))y
_2<\/:~y}}

NB.wc2492
{{(w+i.-q)(I.Q)}(i.w)(I.W)}(#y)#0['q w'=.+/"1'Q W'=.'DI'="0 1 y=.y,'I'}}

NB.wc2501
q=:]`_1:@.(_&=)@([:<./(#~i.@#=10&|))

NB.wc2502
([:>./[:>((_".e.&'0123456789'#])`#@.([:*./e.&((([:,(i.26)+"1 0(,+&32))65){a.)))&.>)

NB.wc2511
{{]`((([:>.2%~#){y)&+)@.(2|#y)([:+/([:i.[:<.2%~#){([:((#~e.&'0123456789')&.":)"1[:|:(,:|.)))y}}

NB.wc2512
(([:,((<./)=])"1*.(((>./)=])"1&.|:))#,)

NB.wc2521
([:+/2^~(#~(0=(1+[:i.#)|#)))

NB.wc2522
{{(q&{.,(q+(0=2|y))&}.)i:q=.<.-:y}}

NB.wc2531
'.'&cut L:0 NB. fixme do it without stdlib

NB.wc2532
(/:+/"1)

NB.wc2541
(0=1|^&1r3)

NB.wc2542
{{((|.q{y)(q=.I.e.&'AEIOUaeiou'y)}])y}}

NB.wc2551
{{'y x'=.x(((y;x)"_)`((x;y)"_)@.(>&#))y
if.1=+/w=.(x([:-.0<[:+/="0 1)y)do.(I.w){y else.w=.y(([:I.(([:+/="0 1)-([:+/(="0 1]))@])){])x end.}}

NB.wc2552
{{(#~(<x)&~:){&zI.([:+./(="1 0(2{.\:~)))+/"1="0 1 z=.((' '&="0 1)<;._1])' '&,y}}

NB.wc2561
(2%~[:+/[:,( ="0 1 |.L:0))

NB.wc2562
{{'y x'=.x(((y;x)"_)`((x;y)"_)@.(>&#))y
x=.(,&(((#y)-#x)#(0{a.)))x
x([:,[:|:,:)y
}}

NB.wc0171
{{if.0=x do.y+1 elseif.(0<x)*.0=y do.(<:x)q 1 elseif.(0<x)*.0<y do.(<:x)q(x q <:y)end.}}M.

NB.wc0172
'^(\w+?://)?((\S+?)(?:(?::)(\S+?))?(?:@))?([0-9A-Za-z\.]+)(?::(\d+))?(/\S+?)*?(?:\?(\S+?))?(?:#(\S+?))?$' rxall 'jdbc://user:password@localhost:3306/pwc?profile=true#h1' NB. rx not exactly pcre or buggy

NB.wc0181
{{(p x)([: > 0 { [: (\:(# S:0))  (([:(#~0&<)[:,[:I.="1 0){[) )(p=.{{r=.'' for_q.1+i.l=.#y do.for_w.i.q do.r=.r,<(l-q-1){.w|.y end.end.r}})y}}

NB.wc0191
((1:`0:@.([:=/0 1&{),(2~:/\]))<;.1])

NB.wc0211
{{+/%!i.y}}bigNum
((1+%)^])bigNum

NB.wc0221
(i.10){([:p:$#:[:I.[:1&=,)@(="0 1(6&+))p:i.1e2

NB.wc0231
NB.wc0232
NB.wc0241
NB.wc0242
NB.wc0251
NB.wc0252
NB.wc0261
NB.wc0262
NB.wc0271
NB.wc0272
NB.wc0281
NB.wc0282
NB.wc0291
NB.wc0292
NB.wc0301
NB.wc0302
NB.wc0311
NB.wc0312
NB.wc0321
NB.wc0322
NB.wc0331
NB.wc0332
NB.wc0341
NB.wc0342
NB.wc0351
NB.wc0352
NB.wc0361
NB.wc0362
NB.wc0371
NB.wc0372
NB.wc0381
NB.wc0382
NB.wc0391
NB.wc0392
NB.wc0401
NB.wc0402
NB.wc0411
NB.wc0412
NB.wc0421
NB.wc0422
NB.wc0431
NB.wc0432
NB.wc0441
NB.wc0442
NB.wc0451
NB.wc0452
NB.wc0461
NB.wc0462
NB.wc0471
NB.wc0472
NB.wc0481
NB.wc0482
NB.wc0491
NB.wc0492
NB.wc0501
NB.wc0502
NB.wc0511
NB.wc0512
NB.wc0521
NB.wc0522
NB.wc0531
NB.wc0532
NB.wc0541
NB.wc0542
NB.wc0551
NB.wc0552
NB.wc0561
NB.wc0562
NB.wc0571
NB.wc0572
NB.wc0581
NB.wc0582
NB.wc0591
NB.wc0592
NB.wc0601
NB.wc0602
NB.wc0611
NB.wc0612
NB.wc0621
NB.wc0622
NB.wc0631
NB.wc0632
NB.wc0641
NB.wc0642
NB.wc0651
NB.wc0652
NB.wc0661
NB.wc0662
NB.wc0671
NB.wc0672
NB.wc0681
NB.wc0682
NB.wc0691
NB.wc0692
NB.wc0701
NB.wc0702
NB.wc0711
NB.wc0712
NB.wc0721
NB.wc0722
NB.wc0731
NB.wc0732
NB.wc0741
NB.wc0742
NB.wc0751
NB.wc0752
NB.wc0761
NB.wc0762
NB.wc0771
NB.wc0772
NB.wc0781
NB.wc0782
NB.wc0791
NB.wc0792
NB.wc0801
NB.wc0802
NB.wc0811
NB.wc0812
NB.wc0821
NB.wc0822
NB.wc0831
NB.wc0832
NB.wc0841
NB.wc0842
NB.wc0851
NB.wc0852
NB.wc0861
NB.wc0862
NB.wc0871
NB.wc0872
NB.wc0881
NB.wc0882
NB.wc0891
NB.wc0892
NB.wc0901
NB.wc0902
NB.wc0911
NB.wc0912
NB.wc0921
NB.wc0922
NB.wc0931
NB.wc0932
NB.wc0941
NB.wc0942
NB.wc0951
NB.wc0952
NB.wc0961
NB.wc0962
NB.wc0971
NB.wc0972
NB.wc0981
NB.wc0982
NB.wc0991
NB.wc0992
NB.wc1001
NB.wc1002
NB.wc1011
NB.wc1012
NB.wc1021
NB.wc1022
NB.wc1031
NB.wc1032
NB.wc1041
NB.wc1042
NB.wc1051
NB.wc1052
NB.wc1061
NB.wc1062
NB.wc1071
NB.wc1072
NB.wc1081
NB.wc1082
NB.wc1091
NB.wc1092
NB.wc1101
NB.wc1102
NB.wc1111
NB.wc1112
NB.wc1121
NB.wc1122
NB.wc1131
NB.wc1132
NB.wc1141
NB.wc1142
NB.wc1151
NB.wc1152
NB.wc1161
NB.wc1162
NB.wc1171
NB.wc1172
NB.wc1181
NB.wc1182
NB.wc1191
NB.wc1192
NB.wc1201
NB.wc1202
NB.wc1211
NB.wc1212
NB.wc1221
NB.wc1222
NB.wc1231
NB.wc1232
NB.wc1241
NB.wc1242
NB.wc1251
NB.wc1252
NB.wc1261
NB.wc1262
NB.wc1271
NB.wc1272
NB.wc1281
NB.wc1282
NB.wc1291
NB.wc1292
NB.wc1301
NB.wc1302
NB.wc1311
NB.wc1312
NB.wc1321
NB.wc1322
NB.wc1331
NB.wc1332
NB.wc1341
NB.wc1342
NB.wc1351
NB.wc1352
NB.wc1361
NB.wc1362
NB.wc1371
NB.wc1372
NB.wc1381
NB.wc1382
NB.wc1391
NB.wc1392
NB.wc1401
NB.wc1402
NB.wc1411
NB.wc1412
NB.wc1421
NB.wc1422
NB.wc1431
NB.wc1432
NB.wc1441
NB.wc1442
NB.wc1451
NB.wc1452
NB.wc1461
NB.wc1462
NB.wc1471
NB.wc1472
NB.wc1491
NB.wc1492
NB.wc1501
NB.wc1502
NB.wc1511
NB.wc1512
NB.wc1521
NB.wc1522
NB.wc1531
NB.wc1532
NB.wc1541
NB.wc1542
NB.wc1551
NB.wc1552
NB.wc1561
NB.wc1562
NB.wc1571
NB.wc1572
NB.wc1581
NB.wc1582
NB.wc1591
NB.wc1592
NB.wc1601
NB.wc1602
NB.wc1611
NB.wc1612
NB.wc1621
NB.wc1622
NB.wc1631
NB.wc1632
NB.wc1641
NB.wc1642
NB.wc1651
NB.wc1652
NB.wc1661
NB.wc1662
NB.wc1671
NB.wc1672
NB.wc1681
NB.wc1682
NB.wc1691
NB.wc1692
NB.wc1701
NB.wc1702
NB.wc1711
NB.wc1712
NB.wc1721
NB.wc1722
NB.wc1731
NB.wc1732
NB.wc1741
NB.wc1742
NB.wc1751
NB.wc1752
NB.wc1761
NB.wc1762
NB.wc1771
NB.wc1772
NB.wc1781
NB.wc1782
NB.wc1791
NB.wc1792
NB.wc1801
NB.wc1802
NB.wc1811
NB.wc1812
NB.wc1821
NB.wc1822
NB.wc1831
NB.wc1832
NB.wc1841
NB.wc1842
NB.wc1851
NB.wc1852
NB.wc1861
NB.wc1862
NB.wc1871
NB.wc1872
NB.wc1881
NB.wc1882
NB.wc1891
NB.wc1892
NB.wc1901
NB.wc1902
NB.wc1911
NB.wc1912
NB.wc1921
NB.wc1922
NB.wc1931
NB.wc1932
NB.wc1941
NB.wc1942
NB.wc1951
NB.wc1952
NB.wc1961
NB.wc1962
NB.wc1981
NB.wc1982
NB.wc1991
NB.wc1992
NB.wc2091
NB.wc2092
NB.wc2101
NB.wc2102
NB.wc2111
NB.wc2112
NB.wc2121
NB.wc2122
NB.wc2131
NB.wc2132
NB.wc2161
NB.wc2162
NB.wc2171
NB.wc2172
NB.wc2181
NB.wc2182
NB.wc2191
NB.wc2192
NB.wc2201
NB.wc2202
NB.wc2211
NB.wc2212
NB.wc2221
NB.wc2222
NB.wc2231
NB.wc2232
NB.wc2241
NB.wc2242
NB.wc2251
NB.wc2252
NB.wc2261
NB.wc2262
NB.wc2271
NB.wc2272
NB.wc2281
NB.wc2282
NB.wc2291
NB.wc2292
NB.wc2301
NB.wc2302
NB.wc2311
NB.wc2312
NB.wc2321
NB.wc2322
NB.wc2331
NB.wc2332
NB.wc2341
NB.wc2342
NB.wc2471

NB. ADVENT OF CODE
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)


NB.aoc2301
NB. part 1
{{q=.0 for_w.<;._1(10{a.),y do.q=.q+([:".(([:<./i.&'0123456789'),(#-(1+([:<./i.&'0123456789')@|.))){])>w end.q}}1!:1<'/path/to/input'

NB. part 2
([:+/[:;[:([:+/[:10 1&*[:(#~0&<)[:,[:|:[:([:({.,:{:)(#~([:+./"(1)0&<)))&.|:((i.9)i.(>:i.9)*[:(((E.~&'one')+.(E.~&'1')),((E.~&'two')+.(E.~&'2')),((E.~&'three')+.(E.~&'3')),((E.~&'four')+.(E.~&'4')),((E.~&'five')+.(E.~&'5')),((E.~&'six')+.(E.~&'6')),((E.~&'seven')+.(E.~&'7')),((E.~&'eight')+.(E.~&'8')),:((E.~&'nine')+.(E.~&'9'))),))&.>[:}:[:<;._1(10{a.)&,)1!:1<'/path/to/input'

NB.aoc2302
NB. part 1
{{+/(>@{.#>@{:)(((*./)&.>),:([:<"0[:>:[:i.#))([:([:(]`([:*./(12 13 14)>:]))@.(a:~:<)[:+/[:>"1[:(<@{{(]`(([:([:{.(#~+./"1))&.|:(E.~&'r'),(E.~&'g'),:(E.~&'b'))*([:".(#~e.&'0123456789')))@.(a:~:<))(((q+1)&}.),((q=.i.&(32{a.)y)&{.))y}});._1','&,);._1 ';',])&.>{:&.|:}:([:<;._1':'&,);._1(10{a.),y}}1!:1<'/path/to/input'

NB. part 2
{{+/;([:*/[:>./[:([:+/[:>[:(<@{{(]`(([:([:{.(#~+./"1))&.|:(E.~&'r'),(E.~&'g'),:(E.~&'b'))*([:".(#~e.&'0123456789')))@.(a:~:<))(((q+1)&}.),((q=.i.&(32{a.)y)&{.))y}});._1','&,);._1 ';',])&.>{:&.|:}:([:<;._1':'&,);._1(10{a.),y}}1!:1<'/path/to/input'

NB.aoc2303
NB. part 1
{{
P=.{{([:>[:{.[:({{(>z),.((z=.([:<"1$#:([:I.[:+./(](1+i.#y)E."0 1,)))y){y)}};])[:([:}:[:;[:(]`(0:&.>)@.(a:=]))[:]`(+/,#$0:)@.(a:~:<)&.>[:<;._1,~&0)"1[:(+./)&.|:[:x&="1 0((2#([:<.[:%:#))$])@((10{a.)&~:#]))y}}
'X z'=.((p=.(([:{(0&{;(1&{+i.@{~&2)))"1))'*=+/&#%-$@'&P y);0
for_q.Y=.p'0123456789'&P y do.
z=.z,(((#~a:~:,)X)([:+./[:;((([:*./1>:[:|-)&.>)/]))((#~a:&~:)q))
end.
'z c y'=.(}.z);0;(];._1(10{a.),y)
for_q.z#Y do.c=.c,".(#~('0123456789'e.~]))(((#~a:&~:)q){y)end.
+/c
}}1!:1<'/path/to/input'

NB. part 2
{{
P=.{{([:>[:{.[:({{(>z),.((z=.([:<"1$#:([:I.[:+./(](1+i.#y)E."0 1,)))y){y)}};])[:([:}:[:;[:(]`(0:&.>)@.(a:=]))[:]`(+/,#$0:)@.(a:~:<)&.>[:<;._1,~&0)"1[:(+./)&.|:[:x&="1 0((2#([:<.[:%:#))$])@((10{a.)&~:#]))y}}
p=.(([:{(0&{;(1&{+i.@{~&2)))"1)
Y=.p'0123456789'&P y
X=.p(,'*')&P y
y=.];._1(10{a.),y
+/*/"1".{&y@(#~(<_)&~:)"1@#&Q"1(#~(2=+/"1)),"2 X(([:+./"1[:;"1((([:*./1>:[:|-)&.>)/])))"0 _ Q=.{{(<_)(([:<"1$#:[:I.[:(a:&=),)y)}y}}Y
}}1!:1<'/path/to/input'

NB.aoc2304
NB. part 1
+/<.(>@{.(2^(1-~[:+/e.))>@{:)"1}:([:<;._1[:1&}._1&".)"1];._1(10{a.),1!:1<'/path/to/input'

NB. part 2 fixme
w=: 0 :0
Card 1: 41 48 83 86 17 | 83 86  6 31 17  9 48 53
Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19
Card 3:  1 21 53 59 44 | 69 82 63 72 16 21 14  1
Card 4: 41 92 73 84 69 | 59 84 76 51 58  5 54 83
Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36
Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11
)

NB. +/ <. ( >@{. ( 2 ^ (1-~ [: +/ e.) ) >@{: )"1 }: ([: <;._1 [: 1&}. _1&".)"1 ];._1(10{a.), 1!:1<'/root/dcs/j/input'
NB. +/<.(>@{.(2^(1-~[:+/e.))>@{:)"1}:([:<;._1[:1&}._1&".)"1];._1(10{a.),1!:1<'/path/to/input'
NB. echo z=.w #~ ({. &. |: ( >@{. (1+[:+/e.) >@{: ) \."1  w=.}:([:<;._1[:1&}._1&".)"1];._1(10{a.),w)

{{
r=.0
y=.}:([:<;._1[:1&}._1&".)"1];._1(10{a.),y
c=.(#y)#1

NB. y #~ ({. &. |: ( >@{. (1+[:+/e.) >@{: ) \."1  y)
for_w.i. # q=.({. &. |: ( >@{. (1+[:+/e.) >@{: ) \."1 y)
do.
echo (w#1),(( ( ((#y) - w)& {. ) &. |.))
NB. echo c=.c+
end.

}}w

NB.aoc2306
NB. part 1
*/([:+/([:*/"1[:(,.|.)[:i.[:>:{.)>{:)"1}.|:}:_".];._1(10{a.),1!:1<'/path/to/input'

NB. part 2
*/([:+/([:*/"1[:(,.|.)[:i.[:>:{.)>{:)"1}:,".(#~e.&'-0123456789');._1(10{a.),1!:1<'/path/to/input'

NB.aoc2308
NB. part 1
{{
s=.0
t=._1&|.('R'=[:>{.)y=.}:<;._1(10{a.),y
'q l r'=.|:([:>"1([:(#~~:&a:)([:-.e.&'ABCDEFGHIJKLMNOPQRSTUVWXYZ')<;._2])&.>)(2&}.)y
p=.q i.c=.'AAA'
while.-.c-:&,'ZZZ'do.
p=.q i.c=.p{l"_`(r"_)@.{.t=.1&|.t
s=.s+1
end.
s
}}1!:1<'/path/to/input'

NB. part 2 fixme
{{
s=.0
t=._1&|.('R'=[:>{.)y=.}:<;._1(10{a.),y
'q l r'=.|:([:>"1([:(#~~:&a:)([:-.e.&'ABCDEFGHIJKLMNOPQRSTUVWXYZ')<;._2])&.>)(2&}.)y
c=.((p=.I.'A'={:"1 q){])q
while.([:+./'Z'~:{:"1)c do.
p=.q i.[c=.p{l"_`(r"_)@.{.t=.1&|.t
s=.s+1
end.
s
}}1!:1<'/root/dcs/j/iaoc2308'

NB.aoc2307
NB.aoc
NB. part 1
q=:1!:1<'/root/dcs/j/iaoc2307'
w=:0 :0
32T3K 765
T55J5 684
KK677 28
KTJJT 220
QQQJA 483
)

r=.{{
select.q=.>./w=.+/'23456789TJQKA'&="1 0 y
 fcase.5 do.
  case.4 do.(2+q)*1+w i:q NB. k4
  case.3 do.
    if.2=([:1&{\:~)y do. NB. fh
      5^~1+w i:q
    else. NB. k3
      4^~1+w i:q
    end.
  case.2 do.
    if.+/2=w do. NB. p2
      3^~1+w i:q
    else. NB. p1
      2^~1+w i:q
    end.
  case.1 do. NB. hc
      1^~1+w i:q
end.
}}

{{
NB. R rank
NB. b bet
NB. y hand
'R b'=.(>@{. ,. ".@>@{:) &. |: ( ( ( r ) &.> @ {.) ,: {:) &. |: Y=.}:([:<;._1(32{a.)&,);._1(10{a.),y
for_w.~.R do.
NB. ( [: (/:((5##)#.'23456789TJQKA'&i.)) [: >"1 {.&.|:)
NB. {{y=.( ( ( ( (<_) ([:I. w  = ]) } ]) @ {.),:{:) &. |:) y}}q2
NB. echo y=.( ( (<"1([: (/: ( (5 # #) #. '23456789TJQKA'&i.) ) ) ) i { y) (i =. I. w = R) } ]) y
NB. echo y=.( ( (<"1([: (/: '23456789TJQKA'&i.) ) ) i { y) (i =. I. w = R) } ]) y

NB. echo y=.(((     [:(/:'23456789TJQKA'&i.)i&{)y)(i=.I.w=R)}])y
i=.I.w=R
([:(/:'23456789TJQKA'&i.)i&{)y
b=.((     [:(/:'23456789TJQKA'&i.)i&{)y) (i) } b
((i{b)+(i.#i))
echo y=.(((     [:(/:'23456789TJQKA'&i.)i&{)y)(i=.I.w=R)}])y

end.
(<"1 y),.(<"1 b)
}}q

NB.aoc2309
NB. part 1
{{w=.0 for_q.i.<:#y=._&".;._1(10{a.),y do.w=.+/({:Q),w,(([:-1+[:+/[:0&={:){"1])(([:|.[:i.#)|."0 1])((0{[:I.([:*./0&=)"1){.])((2-~/\])^:(1+i.#Q)Q=.q{y)end.w}}1!:1<'/path/to/input'

NB. part 2
{{w=.0 for_q.i.<:#y=._&".;._1(10{a.),y do.w=.+/w,{{w=.(#y)#0 for_q.([:i.&.<:#)y do.w=.((q{y)-(q-1){w)q}w end.{:w}}|.,&0({.Q)&,{."1((0{[:I.([:*./0&=)"1){.])((2-~/\])^:(1+i.#Q)Q=.q{y)end.w}}q=.1!:1<'/path/to/input'

NB.aoc2315
NB. part 1
{{o=.0 for_q.([:<;._1','&,)}:y do.o=.o+{{w=.0 for_q.(a.&i.)y do.w=.(256|17*w&+)q end.w}}>q end.o}}1!:1<'/path/to/input'
NB. 0([`((256|(17*[)+a.i.0{])$:}.@]) @.(0<#@]))'HASH'
NB. 0([`( (256|[+17*a.i.0{]) $: (}.@]) ) @.(0<#@]))'HASH'

NB. part 2 fixme
NB. q=.1!:1<'/root/dcs/j/iaoc2315'
w=.'rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7'
{{
for_q.([:<;._1','&,)}:y do.
l=.I.'0123456789'e.>q
if.'='e.>q do.
echo <;._1'='&,>q
else.
echo <;._1'-'&,>q
end.
??
end.
}}w

NB.aoc2313
NB. part 1
{{z=.0 for_g.([:>"1 LF&cut)L:0(2#LF)<{{((#~~:&a:)(0<{:(+_1&|.)^:(i.#x)(x E.y))u;._2 y),{:(#~~:&a:)(0<{:(+_1&|.)^:(i.#x)(x E.y))u;._1 y}}y do.'X Y'=.$g=.>g for_r.|.{{(#~a:&~:)(#~(((0={.)+.((<:y)={:))*.(0=2|#)))L:0,{{r=.''for_q.1+i.l=.#y do.for_w.i.q do.r=.r,<(l-q-1){.w|.y end.end.r}}i.y}}X do.r=.>r if.r([:*./[:,(([:|.-:@#@[{.[){])=((-:@#@[}.[){]))g do.z=.z+1e2*1+0{({~([:(,~<:)[:-:#))r continue.end.end.for_r.|.{{(#~a:&~:)(#~(((0={.)+.((<:y)={:))*.(0=2|#)))L:0,{{r=.''for_q.1+i.l=.#y do.for_w.i.q do.r=.r,<(l-q-1){.w|.y end.end.r}}i.y}}Y do.r=.>r if.r([:*./[:,(([:|.-:@#@[{.[){])=((-:@#@[}.[){]))|:g do.z=.z+1+0{({~([:(,~<:)[:-:#))r continue.end.end.end.z}}1!:1<'/path/to/input'

NB. part 2
{{z=.0 for_g.([:>"1 LF&cut)L:0(2#LF)<{{((#~~:&a:)(0<{:(+_1&|.)^:(i.#x)(x E.y))u;._2 y),{:(#~~:&a:)(0<{:(+_1&|.)^:(i.#x)(x E.y))u;._1 y}}y do.'X Y'=.$g=.>g for_r.|.{{(#~a:&~:) (#~(((0={.)+.((<:y)={:))*.(0=2|#)))L:0,{{r=.''for_q.1+i.l=.#y do.for_w.i.q do.r=.r,<(l-q-1){.w|.y end.end.r}}i.y}}X do.r=.>r if.r([:(+/=([:<:#))[:,(([:|.-:@#@[{.[){])=((-:@#@[}.[){]))g do.z=.z+1e2*1+0{({~([:(,~<:)[:-:#))r continue.end.end.for_r.|.{{(#~a:&~:)(#~(((0={.)+.((<:y)={:))*.(0=2|#)))L:0,{{r=.''for_q.1+i.l=.#y do.for_w.i.q do.r=.r,<(l-q-1){.w|.y end.end.r}}i.y}}Y do.r=.>r if.r([:(+/=([:<:#))[:,(([:|.-:@#@[{.[){])=((-:@#@[}.[){]))|:g do.z=.z+1+0{({~([:(,~<:)[:-:#))r continue.end.end.end.z}}1!:1<'/path/to/input'

NB.aoc2321
NB. part 1
{{i=.($#:[:I.[:'.'&=,)g=.'.'(s=.,($#:[:I.[:'S'&=,)g)}g=.}:];._1 LF&,y NB. 3
{.$([:(#~e.&i"1)[:~.((1 0&+),(-&1 0),(0 1&+),:(-&0 1))"1)^:63~.((1 0&+)"1,(-&1 0)"1,(0 1&+)"1,:(-&0 1)"1)s}}1!:1<'/path/to/input'

NB. part 2 fixme
{{i=.<"1($#:[:I.[:'.'&=,)g=.'.'(s=.<,($#:[:I.[:'S'&=,)g)}g=.}:];._1 LF&,y NB. 1
p=.([:(#~e.&i)[:,((1 0&+);(-&1 0);(0 1&+);(-&0 1))S:0)s
'l s'=.0;$g
while.26501365>l=.l+1 do.
p=.([:(#~([: e.&i s&|L:0))[:~.[:,((1 0&+);(-&0 1);(0 1&+);(-&0 1))S:0)p
end.
$p
}}1!:1<'/path/to/input'

{{i=.<"1($#:[:I.[:'.'&=,)g=.'.'(s=.<,($#:[:I.[:'S'&=,)g)}g=.}:];._1 LF&,y NB. 2
z=.$g
$(([:(#~([: e.&i z&|L:0))[:~.[:,((1 0&+);(-&1 0);(0 1&+);(-&0 1))S:0))^:(26501365-1)([:(#~e.&i)[:,((1 0&+);(-&0 1);(0 1&+);(-&0 1))S:0)s
}}1!:1<'/root/dcs/j/iaoc2321'

{{i=.($#:[:I.[:'.'&=,)g=.'.'(s=.,($#:[:I.[:'S'&=,)g)}g=.}:];._1 LF&,y NB. 3
z=.$g
{.$([:(#~([:e.&i z&|)"1)[:~.((1 0&+)"1,(-&1 0)"1,(0 1&+)"1,(-&0 1)"1))^:100 ~.((1 0&+)"1,(-&1 0)"1,(0 1&+)"1,:(-&0 1)"1)s
}}1!:1<'/root/dcs/j/iaoc2321'

NB.aoc2314
NB. part 1
{{g=.|:|.g=.}:];._1 LF&,y for_q.i.#g do. g=.(]`}.@.((#g)<#);('.'([:I.'e'=])}'O'(([:i.[:+/'e'=]){([:|.[:i.[:#]))}'e'([:I.'O'=])}])L:0<`([:('#'&=<;.1])'#'&,)@.('#'&e.)q{g)q}g end.+/1+0{"1($#:[:I.'O'=,)|:g}}1!:1<'/path/to/input' NB.1
{{+/1+0{"1($#:[:I.'O'=,)|:([:]`}.@.((#g)<#)"1[:;[:('.'([:I.'e'=])}'O'(([:i.[:+/'e'=]){([:|.[:i.[:#]))}'e'([:I.'O'=])}])L:0<`([:('#'&=<;.1])'#'&,)@.('#'&e.))"1 g=.|:|.}:];._1 LF&,y}}1!:1<'/path/to/input' NB. 2

NB. part 2 fixme
{{
g=.|:|.}:];._1 LF&,y
z=._1
while.1000000000>z=.z+1 do.
for_q.i.#g do.
g=.(]`}.@.((#g)<#);('.'([:I.'q'=])}'O'(([:i.[:+/'q'=]){([:|.[:i.[:#]))}'q'([:I.'O'=])}])L:0<`([:('#'&=<;.1])'#'&,)@.('#'&e.)q{g)q}g
end.
g=.|:|.g
end.
echo +/1+0{"1($#:[:I.'O'=,)|:g
NB. }}1!:1<'/root/dcs/j/iaoc2314'
}}0 :0
O....#....
O.OO#....#
.....##...
OO.#O....O
.O.....O#.
O.#..O.#.#
..O..#O..O
.......O..
#....###..
#OO..#....
)

NB. part 3 fixme 156.5-day execution expected
{{'z w'=._1;#g=.}:];._1 LF&,y
NB. +/1+0{"1($#:[:I.'O'=,)|:([:([:]`}.@.(w<#)"1[:;[:('.'([:I.'e'=])}'O'(([:i.[:+/'e'=]){([:|.[:i.[:#]))}'e'([:I.'O'=])}])L:0<`([:('#'&=<;.1])'#'&,)@.('#'&e.))"1[:|:|.)^:4000000000 g
NB. +/1+0{"1($#:[:I.'O'=,)|:4000000000{{([:|:|.)^:(1+4|x) ([:([:]`}.@.(10<#)"1[:;[:('.'([:I.'e'=])}'O'(([:i.[:+/'e'=]){([:|.[:i.[:#]))}'e'([:I.'O'=])}])L:0<`([:('#'&=<;.1])'#'&,)@.('#'&e.))"1[:|:|.)^:x y}} g
+/1+0{"1($#:[:I.'O'=,)|:([:([:]`}.@.(w<#)"1[:;[:('.'([:I.'e'=])}'O'(([:i.[:+/'e'=]){([:|.[:i.[:#]))}'e'([:I.'O'=])}])L:0([:('#'&=<;.1])'#'&,))"1[:|:|.)^:4000000000 g
}}1!:1<'/root/dcs/j/iaoc2314'

NB. arbitrary length, square sudoku solver sudoku
NB. intersection
is=:([-.-.)
NB. creates verbs and nouns for solving (y y)-shaped sudokus
c=:{{)m
  NB. integer, greater 1, scalar, finite
  assert.([:*./(>.=<.),(2&<:),(''-:$),(_&~:))y
  NB. presentation verb
  a=:((2#y^2)$,)f.
  NB. missing numbers of boxed >1-dim
  mn=:((1+i.y^2)&-.@;"2@:(((1=#@>)"0#])"1))f.
  NB. auxiliary noun
  Q=:i.y
  NB. get a cell's corresponding faces', rows', and columns' indicies, boxed, in 3 4 shape
  frc=:3 :'((q;Q;e;Q),(q;w;Q;Q),:(Q;Q;e;r))"_''q w e r''=.y'f.
  NB. hypercube indices
  i=:([:($#:[:I.[:1:"0,)0$~4#])y
  NB. replace all 0s, empty cells, with could-be numbers
  NB. rz=:(i & (  (]) ` (([: < [: is/ ([: mn ([: <"1 [: frc [) { ]) ) (<@[) } ]) @. ( 0 = >@] )"0 @ ( (< @ [) { ] ) )"1 _) NB. fixme
  NB. rz=:{{for_q.i do.y=.(([:<[:is/([:mn(<"1 frc q){]))(<q)}])"_^:(0=[:>(<q){])y end.}} NB. more time and more space, ffs
  rz=:{{r y for_q.i do.if.0=>(<q){y do.y=.(<is/(mn(<"1 frc q){y))(<q)}y end.end.}}f.
  NB. renew a grid's could-be numbers
  rg=:{{r y for_q.i do.if.1<#>(<q){y do.e=.is/(mn(<"1 frc q){y)if.1=#e do.y=.rg(<e)(<q)}y else.y=.(<e)(<q)}y end.end.end.}}f.M.
  NB. if empty (0-containing), amend with the intersection of the missing numbers of its fcrs; elif possibilities (could-be numbers), for each its fcrs, amend w/ its one unique possibility, having removed self, if unique, else, treat as if empty fixme
  it=:{{)m
    NB. return if solved
    if.((^&4>:{:Q)=([:#;))y do.y return.end.
    for_q.i do.
      if.1<#w=.>(<q){y do.
        if.1=#e=.,(>)`((is&(,@;))/)@.(1<#)([:(a:&~:#])<"1@(w(-.@([e.])#[)w((-.@((i.@#@])e.(([(=i.1:)])"0 1)))#])])@;@((1<#@>)#])@:,"2@((F=.<"1 frc q){]))y do.
          NB. |domain error in solv, executing dyad (<00;0 1 2;2;0 1 2),(<00;00;0 1 2;0 1 2),<0 1 2;0 1 2;2...}
          NB. |   y=.rg(<e)(<q)}((-.&e&.>)F{y)    F}y
          try.
            y=.rg(<e)(<q)}((-.&e&.>)F{y)F}y NB. fixme exclude solved cell from fcr to forgo 2. amend?
          catch.
            y
          end.
        else.
          NB. todo check if one possibilities is unique, and, if so, use it
          NB. todo if x possibilitis in any one fcr, of length n have n-1 duplicates, exclude from pool
          NB. if.1=#e=.is/(mn F{y)do.y=.rg(<e)(<q)}((-.&e&.>)F{y)F}y elseif.1<#e do.y=.rg(<e)(<q)}y end.
          y=.(<is/(mn F{y))(<q)}y
          NB. y
          NB. return.
        end.
      end.
    end.
  }}f.
  solv=:(it^:_@rg@rz)f.
  ''
}}f.
c 3
(([: < a),([: < [: a solv))eu1
(([: < a),([: < [: a solv))eu2
(([: < a),([: < [: a solv))hu NB. fail