JohnE
• Member for 6 years, 10 months
• Last seen more than a month ago

CHIP-8, 48 bytes This may not be considered legal, but why the hell not. I wrote my program in CHIP-8, a bytecode-based programming language for a virtual game console. You can try the complete ...

K, 3 bytes ,// This is a fairly common idiom. "Join over converge". try it here with oK. How it works: Join (,) fuses together atoms or lists to produce a list. Over (/) takes a verb (in this ...

K, 5 bytes This has a delightfully elegant solution in K! ~/=:' The "group" operator (monadic =) creates precisely the signature we want for word isomorphism; gathering vectors of the indices of ...

K, 4 bytes #,/\ In K, ,/ will join all the elements of a list. The common idiom ,// iterates to a fixed point, flattening an arbitrarily nested list completely. ,/\ will iterate to a fixed point in ...

K5, 53 45 bytes {{,/(b+a&~b:x*&\a:9=y){$[x;x#" ";y]}'y}[x]'y} In action: {{,/(b+a&~b:x*&\a:9=y){$[x;x#" ";y]}'y}[x]'y}[4;(,"a";"\t\tb\tc";,"d")] (,"a" " b c" ,"d") I ...

K5, 5 bytes Assuming the input is already in a variable called d, ?d^?d Take the distinct elements (?) of d except (d^) the distinct elements of d (?d). Nicely symmetrical, no? This works because ...

K, 11 bytes (3 3#)'!9#2 Output example: ((0 0 0 0 0 0 0 0 0) (0 0 0 0 0 0 0 0 1) (0 0 0 0 0 0 0 1 0) (0 0 0 0 0 0 0 1 1) … This is K's native prettyprinted representation of a ...

Octo/XO-Chip, 70 bytes Octo is a high level assembly language that compiles down into bytecoded instructions for the CHIP-8 virtual machine. Octo provides some custom extensions called "XO-Chip" to ...

iKe, 43 bytes ,(0 0;"|"\"#0055A4|#FFF|#EF4135";52#,&3#26) This is an example of a "raw tuple" iKe program- it's just a description of an origin (0 0), a palette (3 7#"#0055A4#FFFFFF#EF4135") and ...

iKe, 53 51 bytes Nothing particularly special, but I suppose we ought to have at least one graphical solution: ,(80+160*t@&{.5>%(x*x)+y*y}.+t:0N 2#-.5+?9999;cga;3) Try it in your browser. ...

K, 21 bytes 4(|+"#",)/4(|+" ",)/, Enlist the string, Add a space to all four sides of a string, then add an octothorpe to each side of the string. In action: 4(|+"#",)/4(|+" ",)/,"Hello." ("######...

K5, 27 30 26 25 22 bytes "0"{4(|+y,)/x}/"0*+"3!1_! This approach iteratively "wraps" a core (beginning with "0") on all four sides using some other character ({4(|+y,)/x}). The sequence of seasonal ...

K5, 6 bytes *>#:'= The first (*) of the descending elements (>) of the count of each (#:') of the group (=). Step by step: i 4 3 1 0 6 1 6 4 4 0 3 1 7 7 3 4 1 1 2 8 =i 4 3 1 0 6 7 2 8!(0 ...

K, 123 110 bytes I used a similar approach to cardboard_box's solution. r:{y,x#,*|y};h:{t:(#x)|#y;r[t-#x;x],'r[t-#y]y};a:{(,x .|2#y),2_ y};*(){(a[{+h[+x;+y]}]x;a[h]x;(,,y),x)"-|"?y}/ This program ...

K, 143 129 113 bytes 1!"}int a[99];int*p=a;main(){",,/{("p++;";"p--;";"*p++;";"*p--;";"*p=getchar();if(*p<0)*p=0;";"putchar(*p);";"while(*p){";"}";"")"><+-,.[]"?x}' This is an extremely ...

K, 7 3 bytes {y+\/x} Very similar to the J solution. +\ precisely performs a partial sum, and when / is provided with a monadic verb and an integer left argument it iterates a specified number of ...

K5 This is a thin, simple wrapper around my JavaScript based K implementation, oK, and references the github repo. I've already built a much nicer browser-based frontend. oK implements a very ...

oK, 37 32 24 23 bytes +/(10/{%x*x}1_-':.:'$)\ In action: +/(10/{%x*x}1_-':.:'$)\8675309 8898683 (+/(10/{%x*x}1_-':.:'$)\)'!20 0 1 2 3 4 5 6 7 8 9 11 11 13 15 17 19 21 23 25 27 K5 has a few ... View answer 5 votes Calling a Dyad Assuming you had a dyadic (2-argument) function f: f: {x+2*y} You would ordinarily call it like so: f[3;47] You can save a character by instead currying in the first argument and ... View answer 5 votes K, 22 21 bytes {,//+(y@<z;(z@<z)_ x)} We define a 3 argument function {…} with the implicit variables x, y and z representing the starting list, the value list and the index list, respectively.... View answer 5 votes K, 19 bytes {x#'![1]\(x#" "),y} Tack x spaces (x#" ") onto the beginning of the string y. Then use the "fixed-point scan" form of the operator \ to create the set of rotated strings. A fixed-point ... View answer 4 votes Kerf, 73 bytes Kerf is a proprietary language in the same general family as APL, J and K. It's possible to write cryptic, compact oneliners and avoid the use of explicit loops: {[s]s:_ s;n:?isnull i:... View answer 4 votes K5, 15 bytes Very literal: {(+/x%2;%*/x)}/ In action: {(+/x%2;%*/x)}/[0; 24 6] 24 6 {(+/x%2;%*/x)}/[5; 24 6] 1.345817e1 1.345817e1 Unfortunately, this does not work in oK because that ... View answer 4 votes K5, 55 51 bytes " "/(" hour";" minute"){y,x,("s";"")1=.y}'$25 60\.*" "\ This is more general than it strictly has to be; might still golf it down further. In action: f: " "/(" hour";" minute"){y,...

K, 11 bytes {x@&~x<|\x} In action: f: {x@&~x<|\x} f'(1 2 5 4 3 7 10 -1 12 -7 -8 -5 0 -1 1 9 8 7 6 5 10 13 17 21 10 10 10 9 10) (1 2 5 7 10 12 -7 -5 0 1 ...

K5, 19 bytes Not particularly clever: t:-1;r:{t::*1?10^t} Each time r is invoked, it picks 1 random number (*1?) from the set formed by taking the range 0-9 except (^) the previous random number ...

K, 48 bytes {{0:1_',/'(1+#$|//x)$x}(x-1){+|x,\:t#t:#x}/,,1} And in action: {{0:1_',/'(1+#$|//x)$x}(x-1){+|x,\:t#t:#x}/,,1}7 8 8 8 8 8 8 8 8 5 5 5 5 5 8 8 8 8 8 8 8 8 5 5 ...

K, 25 bytes #1_{~x~|x}{$. x,"+",|x}\$ Not very elegant. The overall form ({monad 1}{monad 2}\x) is K's equivalent of a general "while" loop, where the first monad is the halting condition and the ...