15

APL (Dyalog Unicode), 20 12 bytesSBCS -6 bytes through dzaima Full program. Prompts stdin for: texture as a list of strings number of rows in shape matrix number of columns in shape matrix indices of falsies (to be blanks) in the shape matrix All the ⎕s are supposed to be rectangles (they're not tofu). They symbolise a computer console which here means ...


14

JavaScript (ES6),  259 249  246 bytes Takes input as an array of integers. Returns a matrix of characters. a=>{for(m=[],i=a.length,X=i+25;i--;r[X]>' '|!w?0:r[X]='_',X--)for(y=w=a[i];y>=-w;y--)for(r=m[Y=y+25]=m[Y]||Array(X).fill` `,W=w+(y>0?1-y:y),k=2;k--;)for(x=-W;x<W;x++)r[X+x+k]='/\\ _'[w^a[i+k]|w^a[i+k-1]?(x+W&&2-!(~x+W)...


13

JavaScript (ES6), 98 bytes n=>` _/|2 | |\\0 |_ |/1 \\|3`.replace(/\d/g,k=>n?(k&1?' /':' \\').repeat(n/33^n>98):['/\\'[k]]) Try it online! How? We use the following template: _/|2 | |\0 |_ |/1 \|3 If \$n=0\$ (volume muted): \$0\$ is replaced with / and \$1\$ is replaced with \ the other digits are removed If \$n\neq 0\$: odd ...


9

Canvas, 9 bytes m⤢m⤢;n← ╋ Try it here! Abusing that the input will be ASCII and so won't contain ←, but the shape is made of spaces and ← for easy overlapping and replacement. Alternative 12 bytes taking shape as space and #.


7

05AB1E, 65 64 bytes „ /SõD‚„\ ‚D4δ∍D)T•4a֙镓| 0\ 1/“ÅвJrI33÷IĀ+©è‡∊'_1•uтÄ•22в®è‚ǝ When I started I thought I would be able to make this pretty short with the approach I had in mind, but it had some annoying edge cases to fix.. Can definitely be golfed, though. Will take another look later on. Try it online or verify some more test cases. Explanation: ...


7

MATL, 33 30 27 26 bytes ii:"l1G1=aYm/t&Y"1Gy1=(]Zc Input is a numerical matrix with 0 for empty, 9 for filled and 1 for recursive. Replaces recursive by filled at the end. Output is a character matrix with  (space) for empty and # for filled. Try it online! Or verify all test cases. Explanation i % Take first input: matrix, M. This will ...


7

Python 2, 131 125 bytes f=lambda A,p=1:map(''.join,zip(*[re.sub('\+.+\+',lambda x:re.sub('\.','*',x.group()),s)for s in p and f(A,0)or A])) import re Try it online! Input is a list of strings; as is output.


6

Python 2, 111 101 90 bytes n=input() for s in'\ _/|','\| |\/','/|_ |/\\','/ \|':print s[1:6+0**n],s[:n>32],s[:n/66] Try it online! -11 bytes, thanks to xnor


6

Lua, 308 259 246 242 219 180 bytes i=io.read("*n") print(i<1 and[[ _/| | |\/ |_ |/\ \|]]or i<33 and[[ _/| | |\ |_ |/ \|]]or i<66 and[[ _/| \ | |\ \ |_ |/ / \| /]]or[[ _/| \ \ | |\ \ \ |_ |/ / / \| / /]]) Try it online! New to code golf and coding in general. Thanks to all comments for their help!


6

Jelly, 32 28 bytes ³,Z¬ÆmṀ$€İḞ¤xZ¥ƒYṣ0ż³F¤FỴµ¡! Try it online! A full program that takes two arguments, a matrix of integers (0-2) and the number of steps and returns a matrix of integers (1-2). 0 is used for the recursive bit. Thanks to @JonathanAllan for saving two bytes! Explanation (outdated) µ¡ | Repeat the following ...


6

Jelly, 12 bytes ẒT.ịr/Ṭ»)Z$⁺ A monadic Link accepting a list of lists where: crosses, +, are 2 spaces, ., are 0 which yields a list of lists as above with poppies, *, as 1. Try it online! Or see one which translates IO. How? ẒT.ịr/Ṭ»)Z$⁺ - Link: list of lists $ - last two links as a monad - i.e. f(Rows): ) - for each Row in ...


6

Japt, 10 bytes ËmÈ?VgEY:S Try it ËmÈ?VgEY:S U = shape as 2d array, V = texture as list of lines Ë Map each row, define E as row number mÈ Map each element in these rows, define Y as element number ? Is the value a 1? VgEY Get the character at texture[E,Y] :S Else ...


5

Python 3, 163 bytes def f(g,s=[]):w=len(g[0])+1;k=' '.join(g)+w*' ';*p,x=s or[k.find('#')];return' '<k[x]and{x}-{*p}and[min(f(g,s+[x+a])or len(k)for a in(-1,1,-w,w)),len(p)]['+'<k[x]] Try it online! Uses # for start and @ for end. Finds all paths along + and returns the shortest. Each path ends when either a space is encountered, the range is ...


5

Add++, 56 bytes L,"&|\/^.oOv.oO ((("4$Tz£:BF"("+@32C3*$+Bh$2D-1A:1+")"*J Try it online! Add++ is not the best at string manipulation challenges How it works We create an lambda function that takes a single argument - a list of integers - and outputs the final pumpkin. L, - Define our function. Takes in a four element list e.g. [...


5

PowerShell, 96 bytes param($a)$a=&($g={($a=$a-replace'(?<=\+.*)\.(?=.*\+)','*')[0]|% t*y|%{-join$a.chars($i++)}});&$g Try it online!


5

J, 32 bytes 4 :'y}'' '',:x({.@]$($"1~{:))$y' Try it online! Some notes: This was a rare case where I got a shorter solution with an explicit, rather than tacit, verb. I wanted a solution that didn't prompt for input (ie, didn't want to just translate Adam's excellent APL solution into J).


4

JavaScript (ES6), 219 bytes Takes input as a list of lists of characters. a=>((g=(X,Y,D,n=o=0)=>!(a+0)[n++]|a.some((r,y)=>r.some((c,x)=>D=='975'[i='-| #+$'.indexOf(c),x-X+1]-'450'[y-Y+1]?i-3?i-2?i>3?[3,0,7,4].some(d=>D^d^4&&g(x,y,d,n)):~i&&i^D&1?0:g(x,y,D,n):0:o=-n:X+1|i<5?0:g(x,y,2))))(),~o) Try it online! How? ...


4

JavaScript (ES6), 78 bytes (s,e,m,w)=>` ${'&|\\/'[s]} ${' ('[w]}(${(e='^.oO'[e])+'v.oO'[m]+e})`+' )'[w] Try it online!


4

Python 3 (+ numpy), 183 bytes Assuming the input can be passed in as a numpy character array, here is a different approach. It works by calculating a distance matrix from the start point by repeatedly 'diffusing' distances along roads. Uses '#' for start and '@' for end. from numpy import* def f(A): B=(A!=" ")-1+(A=="#") for _ in nditer(A):B=pad(B,1);B+=(...


4

Japt -h, 16 bytes 2Æ=Õ®Ëd0E©nFÊÉ}S No regex! Try it 2Æ=Õ®Ëd0E©nFÊÉ}S U = input 2Æ 2 times do: = Set U to Õ U transposed ® Map each row: Ë }S Split each row on spaces (crosses), and pass each chunk through the ...


4

J, 44 bytes '.*+'{~[:(+:+-.*](+.|:)&(>./\.*>./\)|:)=&'+' Try it online! No regex used: Takes the product of the max scan of the prefixes and the max scan of the suffixes to turn the in-between cells to 1. Does this for both the input and its transpose (to get both directions) "Or"s these two matrices. Multiplies by one minus the input, to ...


4

Jelly, 18 14 bytes UÄUaÄa2 ZÇZoÇ_ Try it online! -4 bytes because I figured out what I did wrong with my cumulative sums Input and output is as two-dimensional lists with . mapped to 0, + mapped to 1, and * mapped to 2. (The footer on TIO converts automatically for convenience.) Helper link: a2 Fill in 2s wherever Ä there's ...


4

JavaScript (ES8),  298 ... 272  267 bytes Takes input as an array of strings. a=>`BOOM! ${a.map((s,y)=>s.replace(/ _*(L?)_*(?= )/g,(s,L,x)=>t+=(w=s.length,L?y&&s[d=w+1>>1]+a[y-1][k=w*2-1,x+d]=='L+'&&~-w:k=w/3|0)*(v=L?0:++k+1>>1,g=c=>!--k||(a[y+k]+g).indexOf('|'.padEnd(w,c)+(--v?'|':'L-*'),x)==x&g())`_`),...


3

c: 151 116 115 Just giving it a whirl i,j,a;main(c,v)int**v;{for(a=atoi(v[1]);i<a;i+=puts(""))for(j=0;j<a+i;)putchar(++j<a-i?32:42);printf("%*s",a,"*");} Readable code: i, j, a; main(c, v) int **v; { for (a = atoi(v[1]); i < a; i += puts("")) for(j = 0; j < a + i;) putchar(++j < a - i ? 32 : 42); printf("%*s"...


3

Ruby, 139 138 bytes ->s,n{w=(((s=s.chars*' ').size/n=n.hex)**0.5).to_i+k=1&~n (0..h=w+n/5*~-w).map{|i|s.slice!(0,[w+n/6*~-w,w**k+i,w+h+~i].min*2).center w*4}} Try it online! A function taking 2 arguments: a string s and a shape n as a single character in hexadecimal of value 1,2,6 or A. It returns an array of strings. Explanation The input string ...


3

JavaScript (ES8),  191 176 174  171 bytes Takes input as (type)(string), where the 1st parameter is 0123 instead of TSHO and the 2nd parameter is an array of characters. i=>g=(s,n=1,p=0)=>s[o=(h=k=>k?(F=j=>j?s.slice(p,p+=w+=k&6?k&2&&1:-1).join` `.padStart(n*2+w)+` `+F(j-1):'')(n-k%2)+h(k>>3):'')([2,4,10,106][i],w=...


3

PowerShell, 113 bytes param($n)' _/|'+($y=' \'*($x=($n-ge33)+($n-ge66))) '| |\'+($y,'/')[!$n] '|_ |/'+(($z=' /'*$x),'\')[!$n] " \|$z" Try it online!


3

Python 2, 250 249 280 266 250 248 bytes def f(p,n): s=p;Q=L(p[0]) for z in R(n):u,y=[(Q/r.count('_'),y)for y,r in enumerate(s)if'_'in r][0];s=[''.join(s[j/u][i/u]for i in R(u*L(s[0]))).replace('_'*Q,p[(j-y*u)%L(p)])for j in R(u*L(s))] return[c.replace('_','#')for c in s] R=range;L=len Try it online! Input and output are both lists of strings.


3

Japt, 35 bytes Ê/Uèø0 NÌÆ=c@VÇXmpV r0@NάgT° ®r0Q Try it


3

JavaScript (Node.js), 85 bytes a=>(g=m=>m[0].map((_,i)=>m.map(l=>l.join``.replace(/(?<=x.*)-(?=.*x)/g,8)[i])))(g(a)) Try it online! Input / Output as character matrix. Use x for +, - for ., 8 for *. First, convert dots . between two crosses + in a row into star *. l.join``.replace(/(?<=\+.*)\.(?=.*\+)/g,'*') Then. rotate the matrix a=...


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