Posts by torres
J, 4 unique, 4 char -:=_ How it works: -: results in half of what's on the right = results in signum of what's on the right _ is infinity
J, 19 char Solution: (e.&'aeiouAEIOU'#]) Test examples: (e.&'aeiouAEIOU'#]) '' (e.&'aeiouAEIOU'#]) 'Rhythm' (e.&'aeiouAEIOU'#]) 'a' a (e.&'aeiouAEIOU'#...
J, 35 char <:#-:`(>:@:*&3)@.(2&|)^:(1&<)^:(<_) How it works: NB. <: subtract one from number result on right NB. # count number of items from list result on righ...
J, 8 char Solution: |:|.|."1 Test example: (i. 3 3) 0 1 2 3 4 5 6 7 8 |:|.|."1 (i. 3 3) 8 5 2 7 4 1 6 3 0 (i. 4 2) 0 1 2 3 4 5 6 7 |:|.|."1 (i. 4 2) 7 5 3 1 6 4 2...
J, 39 char Solution: (a.{~ a.((6|.8{.1)+.(_8&{.))&.#:"0@i.]) Test example: (a.{~ a.((6|.8{.1)+.(_8&{.))&.#:"0@i.]) '([({Enclosed})])A@B.c' ({({enclosed})})a`b.c How it ...
J, 46 char Solution: (]#~[:([:*./(<./,>./)~:"0 1])([:+/"1@#:a.&i.)) Test example: (]#~[:([:*./(<./,>./)~:"0 1])([:+/"1@#:a.&i.)) 'oAPwSoeHcoDretMBBoesoBsagHDoew' Secre...
J, 7 char *./~:q: How it works: 'q:' produces prime factors of number on right '~:' replaces the first instance of unique numbers with a 1, the rest 0 '*./' tests for all ones Sample runs: ...
J, 13 char '*',^:(<_)'*' How it works: What's in parenthesis indicates to the verb ^: that the verb to the left of ^: has to be performed to the object on the right of the ^: an infinite nu...
J, 46 char ({.(+/m)#a),{:(+/"1 m=:x=+/~a)#a=:p:i._1 p:x=: Sample runs ({.(+/m)#a),{:(+/"1 m=:x=+/~a)#a=:p:i._1 p:x=:4 2 2 ({.(+/m)#a),{:(+/"1 m=:x=+/~a)#a=:p:i._1 p:x=:6 3 3 ({.(+/m)#a),{:...
J, 5 char 2>#~. How it works: '~.' produces list of unique elements of list on its right '#' counts how many elements in the list on its right '2>' tests if number on its right only ha...
J, 7 char '+/',": Sample runs: '+/',": 6 +/6 +/6 5 11 '+/',": 55 +/55 +/55 45 100
J, 36 char {._2{(}.,~(=<.)@v{.@#v=.}.*{.)^:(<_) Sample runs: {._2{(}.,~(=<.)@v{.@#v=.}.*{.)^:(<_) 1096135733 78r55 5r3 1r5 11r2 5r7 328842888196762472689573703 {._2{(}.,~(=...
J, 29 char ('!',~'Hello, ',1!:1<1)1!:2<4 Sample run ('!',~'Hello, ',1!:1<1)1!:2<4 torres Hello, torres!
J, 46 char 'ABCDE'{~<:0 128 192 224 240 I.>:".{.}.;.1'.', Sample runs 'ABCDE'{~<:0 128 192 224 240 I.>:".{.}.;.1'.', '127.255.255.255' A 'ABCDE'{~<:0 128 192 224 240 I...
J, 24 char ([: +/ [: (* +/\ )"1 ~. ="0 1 ]) Sample Runs ([:+/[:(*+/\)"1~.="0 1]) 1 1 2 2 2 1 1 1 3 3 1 2 1 2 3 3 4 5 1 2 ([:+/[:(*+/\)"1~.="0 1]) 3 7 5 4 9 2 3 2 6 6 1 1 1 1 1 1 2 ...
J, 30 char ((2*%:2)%~(1+%:2)&^-(1-%:2)&^) ((2*%:2)%~(1+%:2)&^-(1-%:2)&^) 0 0 ((2*%:2)%~(1+%:2)&^-(1-%:2)&^) 1 1 ((2*%:2)%~(1+%:2)&^-(1-%:2)&^) 2 2 ...
J, 17 char +/`5:@.(2*./@:=]) How it works: What's within parentheses tests if both numbers on the right are 2. If so, the verb agenda @. selects the verb 5: which is always 5. If not, the ve...