# Tag Info

11

Jelly, 8 bytes ⁵Œ!’³ịⱮQ Times out on TIO, takes about two minutes on my machine: % time python3 -m jelly eu '⁵Œ!’³ịⱮQ' "[1,2,3,1]" [[0, 1, 2, 0], [0, 1, 3, 0], [0, 1, 4, 0], [0, 1, 5, 0], [0, 1, 6, 0], [0, 1, 7, 0], [0, 1, 8, 0], [0, 1, 9, 0], [0, 2, 1, 0], [0, 2, 3, 0], [0, 2, 4, 0], [0, 2, 5, 0], [0, 2, 6, 0], [0, 2, 7, 0], [0, 2, 8, 0], [0, 2, ...

9

APL(Dyalog Unicode), 118 114 90 88 83 80 bytes SBCS {⊃,/⍪⌿⍵{' '⍺[⍵]}¨1+(⍺ ⍺∘⍴¨o(⌽o←∘.=⍨⍳⍺)i(⌽⍺/⍺↑1)(⍉⍺ ⍺⍴i←(⌈⍺÷2)=⍳⍺)0)['\/|_- '⍳⍵]} Try it on APLgolf! A dfn submission which takes a char matrix on the right and a scale factor on the left. Indexes each character into its specific pattern, and then uses the original matrix to index back into it. More byte ...

9

Python 2, 41 bytes s=':-' exec"print s[:-1];s+=')';"*input() Try it online! 42 bytes s,c=':-' exec"print s;s+=c;c=')';"*input() Try it online! 43 bytes s=':' exec"print s;s+='-)'[s>':'];"*input() Try it online!

7

C (clang), 170 147 143 137 bytes a,j,i;f(*m,x,z){for(;*m;m+=x)for(j=z;j--;puts(""))for(i=-1;++i<x*z;putchar((a-92?a-47?a-45?a-95|j:j-~j-z:i%z-j:~j+z-i%z)?32:a))a=m[i/z];} Try it online! thanks to @ceilingcat suggestion ! added for loop instead of recursion thanks to @Johan du Toit for suggesting using int*array as input! f(*m,x,z){ ...

7

V (vim), 311 bytes "aDj:%s:$$[ \-_]$$:=repeat("\\1",a) :g :%s:\\:\\=repeat(" ",a-1) :g :%s:/:=repeat(" ",a-1) /:g :%s:|:=repeat(" ",a/2) |=repeat(" ",a/2) :g {qqYp:s:\\ : \\:ge :s: /:/ :ge qdkG{Go ggqtjjkk@a@qdd@tq@tggqb@ajk:s:_:Y:ge j@bq@bi=a/2+1 D@"kkqc:s:-:X:ge @ak@cq@c:%s:[-_]: :g :%s:...

7

Jelly, 9 bytes “:-)”ṁ«\) Try it online! Outputs an array of lines. ) Map over (the range from 1 to) the input: “:-)”ṁ Mold ":-)" to the shape of the argument, cycling its contents. «\ Scan by minimum: replace anything to the right of ) with ). Thanks to Jonathan Allan for salvaging my first attempt, ”)xⱮa⁾:-, for ...

6

APL (Dyalog Unicode), 32 29 bytes Full program, prompting for s and then for f. ¯1↓r⊣⎕{1↓r,∘⊃←⍺⍺⍵}⍣{⍬≡⍺}⎕⊣r←⍬ Try it online! r←⍬ initialise the result variable to the empty list ⎕⊣ dismiss that in favour of s from stdin ⎕{…}⍣{⍬≡⍺} get f from std and use it as follows until the result is the empty list:  ⍺⍺⍵ apply f to the current s (returning [e,t] or [])  ...

6

Factor, 37 36 bytes [ collector [ follow ] dip 1 head* ] Try it online! -1 byte thanks to @chunes Takes initial-value and quotation on the stack, and returns a vector. The input quotation should return next-state next-value on the stack, or f f to terminate. some-quot collector [ high-order-func ] dip is a pattern to snatch the top of the stack of every ...

6

K (oK), 261 184 165 163 159 bytes {k:y;v:" ";a:{[g]{(x#v),g,(k-x+1)#v}'!k};h:{[s]{k#s@x=_k%2}'!k};,/{,/'+{$[92=x;a x;47=x;|:'a x;45=x;h v,x;95=x;{k#" _"@x=k-1}'!k;v=x;(k;k)#v;+h v,x]}'x}'";"\x} Try it online! I lost my sanity several times while creating this. Thanks to ngn and Razetime for helping me with this. Thanks to ... 6 APL (Dyalog Unicode), 12 bytes Anonymous tacit prefix function. ⊂(∨/=,1∊⊢)¨⍳ Try it online! ⊂(…)¨⍳ apply the following tacit infix function between the entire argument and each index in an array of those dimensions: 1∊⊢ is there a 1 in the index? =, prepend a Boolean list indicating which coordinate are equal to the corresponding element of the original ... 6 APL(Dyalog Unicode), 11 bytes SBCS ⊢↑1∘-↑-∘2⍴≡ Try it on APLgolf! Sometimes the most straightforward method wins. Space is 1, wall is 0. How it works ⊢↑1∘-↑-∘2⍴≡ Monadic train; ⍵←dimension vector -∘2⍴≡ Create the core of ones of dimensions of ⍵-2 1∘-↑ Prepend a layer of zeroes by overtaking ⍵-1 in reverse ⊢↑ Append a layer ... 5 Julia 1.0, 138 130 bytes !a=(z=1:size(a,1);~a=all(sum([a].^z).>0);a/i=any(j->a[i,j]>0&&(a[[j,i],i]=0:1;a[j,j]>0||+a/j),z);[a!=a',any([+a]./z),~a,~(a.|a')]) Try it online! Takes input as an adjacency matrix (In TIO footer it is constructed from edge list by adj function), outputs a boolean array with the following members: [directed? ... 5 J, 89 bytes [(a{~[:,/[:,./"3[*({0:0}(,:|.)@=@i.,/@,~(1,>.@-:)(,:~|:)@|."{1:0},~$0:))~(a=.' _|-\/')i.] Try it online!

5

Charcoal, 33 bytes ＮθＧ↙↘→→↗↖θ⎇﹪θ³“⟲∧ＬＶoIＧ；”“⟲∧⦄≧Σ¶ζ； Try it online! Link is to verbose version of code. Explanation: After reading in n, the code simply draws a hexagon using one of two fill patterns depending on whether n is a multiple of 3; if it is, the fill pattern has the * one - in from the corner, otherwise it has the * in the top left corner.

5

Jelly, 7 bytes R%)Ịoþ/ A monadic Link that accepts the dimensions as a list of positive integers ordered by depth descending (like the examples in the question) and yields the room as a multi-dimensional list of 1s and 0s. Try it online! Or see the test-suite How? R%)Ịoþ/ - Link: list of positive integers, Sizes ) - for each (size in Sizes): R - ...

5

Factor + math.combinatorics, 50 bytes [ 10 iota [ nths ] with map-permutations members ] Try it online! Port of @Lynn's Jelly answer. 10 iota The digits from 0 to 9. [ ... ] with Include the input in a quotation. [ nths ] map-permutations Map the permutations of 0-9 to the indices given by the input. members Remove duplicates.

5

K (ngn/k), 14 11 bytes |/~&/|:'\!: Try it online! @ngn suggested a 13-byter {|/~x&|'x:!x} in chat, which overwrites x with the odometer (x:!x), takes element-wise minimum & with its row-wise reverse |'x, and then does |/~ as below. The 11-byter above is the result of x f g x trainifying tip. 1 in 1|:'\ can be omitted because odometer's reverse ...

4

Gol><>, 34 bytes 'r2sslK5+:l)?H1sh"r2sslK5+:l)?H1sh Try it online! This is composed of two identical sections of code, except one uses ' and the other uses ". The combined program outputs 17 (which is only one byte away from being able to use a single instruction to push the number), which splits them into practically identical programs. ...

4

Wolfram Language (Mathematica), 26 bytes f=#@#2/.{a_,b_}:>b<>#~f~a& Try it online! Input [f, s]. Returns a StringJoin of elements. Expects an empty list to indicate the list has ended. To output a list, +6 bytes: f=#@#2/.{a_,b_}:>{b,##&@@#~f~a}& Try it online!

4

J, 27 bytes 1 :'[:(#~2|i.@#)(,u@{:)^:_' Try it online! This is J adverb, which modifies a verb returning (new element, new state) to create the required unfold verb. (,u@{:)^:_ Keep appending unfold's results until a fixed point, re-applying the verb to the last element on every iteration. [:(#~2|i.@#) Keep only odd indexed elements, ie, the elements only, ...

4

K (ngn/k), 22 bytes {-1_1_*'|'{x}(y@*:)\x} Try it online! call with f[n,s]. s should return an array (nextState;digit) and return a falsy value when it's supposed to end. I can remove {x} but that would make the function stop on a repeated state. Although that is unlikely, it doesn't seem right to reject that. Explanation {-1_1_*'|'{x}(y@*:)\x} ...

4

Python 3, 67 bytes Prints the 0-based sequence forever. d=n=k=0 while 1:k+=1;k**=k*k<=n;n+=k<2;k+n&1<(k>1%n)!=print(d);d+=1 Try it online! Commented: d=n=k=0 while 1: k+=1 # increment k k**=k*k<=n # k=k**1=k if k*k<=n, else k=k**0=1 n+=k<2 # increment n if k is equal to 1 ...

4

Vyxal D, 12 bytes q\:Ė\+:Ė Try it Online! What differences this from the other quine is an eval quine so is easily payload-capable - that is, all the processing code you need can go after the + and only needs to be iterated once. Will be 9 bytes once parsing bugs get fixed.   # String of code to be executed q # Quotify / uneval \`...

4

ARM T32 machine code, 48 bytes b570 0084 2000 e00f 590a 594b 18d2 598b 18d2 230b 435a f012 3f0c bf08 3001 3e04 d5f2 3d04 1f2e d5ef 3c04 1f25 d8fa bd70 Following the AAPCS, this takes the number of cards in r0 (permitted here; this can handle an arbitrary number of cards), and in r1 the address of the cards as an array of size-4 arrays of 8-bit integers, and ...

4

tinylisp, 46 bytes (d U(q((S F)(i(F S)(c(h(t(F S)))(U(h(F S))F))( Try it online! Ungolfed Implements the spec directly: (load library) (def unfold (lambda (val func) (if (func val) (cons (head (tail (func val))) (unfold (head (func val)) func)) nil))) This approach is pretty inelegant: it's not tail-recursive, and it ...

4

Python 3.8 (pre-release), 92 bytes f=lambda n,i=0:[l:=' '*(n-i)+('- * - '*n)[n%3%2+i<<1:][:n+i<<1]]+(n>i+1and[*f(n,i+1),l]or[]) Try it online!

4

Python 3.8 (pre-release), 254 bytes n=-2,-1,1,2,2,1,-1,-2 l=len e=enumerate s=lambda b,x,y,t:max([1>((a:=[p:=x+_,q:=y+n[i-6]])in t)<l(b)>p>-1<q<l(b[p])>0<b[p][q]and[i]+s(b,p,q,t+[a])or[]for i,_ in e(n)],key=l) f=lambda b:max([(z:=[x,y])+s(b,*z,[z])for x,r in e(b)for y,c in e(r)if c],key=l) Try it online! Pass input to the function f ...

4

4

JavaScript (ES6), 65 bytes Expects the input list in reverse order. Very similar to the 66-byte version, but returns a flattened string. f=([n,...a],b='0')=>n?b.replace(/./g,v=>f(a,1+v.repeat(n-2)+1)):b Try it online! JavaScript (ES6), 66 bytes Expects the input list in reverse order. f=([n,...a],b=[0])=>n?b.map(v=>f(a,[1,...Array(n-2).fill(v)...

4

Octave with Image Package, 25 bytes @(d)padarray(e(d-2),+~~d) Anonymous function that inputs a vector with the coordinates and outputs an n-dimensional array. Wall and space are respectively 0 and e (equal to 2.71828...) Note that, when displaying, the first dimension corresponds to the vertical direction. Try it online! Explanation @(d)padarray(e(d-2),+~~...

Only top voted, non community-wiki answers of a minimum length are eligible