New answers tagged

0

GolfScript, 13 bytes 4*.' '\++3/n* Try it online! Explanation # input # 4* # ["####"] . # ["####","####"] ' ' # ["####","####"," "] \ # ["####"," ","####"] ++ # ["#### ####"] 3/ # [["###" "# #" "###"]] n* # [["###\n# #\n###"]]


1

PHP, 918 870 650 bytes [$z,$h]=json_decode($argn);$j=$h-1;$p=array_fill(0,$c=100,[0,array_chunk($z,ceil(count($z)/$h))]);$r=fn($x)=>rand(0,$x);g:foreach($p as&$s){$b=[];for($s[0]=$l=0;$l<$h;$l++){for($m=$k=0;$k<~-count($v=$s[1][$l]);)$b[$l][]=$m+=$v[$k++];$s[0]+=abs(array_sum($z)/$h-$m-$v[$k]);}for($l=0;$l<$j;){if(array_intersect($b[$l]??[],$...


1

05AB1E, 36 bytes œIδ.Œ€`ʒOË}.ΔεηO¨}üåà≠}<·'_×€€…[ÿ]J» Slow brute-force approach (already times out for the last test case on TIO), but it works. First input is the list of brick sizes and second input is the height integer. Try it online or verify a few test cases at once. Explanation: First get all possible ways to divide the list of bricks into ...


1

PowerShell, 266 bytes param($b,$h)$w=($b|%{'['+'__'*--$_+']'})+," "*--$h|sort;filter p{if($k=--$_){$k|p;0..($k-1)|%{$j=($_,0)[$_%2];$w[$j],$w[$k]=$w[$k,$j] $k|p}}else{,(-join$w-split" ")}}$w.Length|p|?{!(($x=($a=$_)|% Le*|gu).Rank-or-join(1..($x-2)|%{$a|% Ch* $_})-match']]')}|select -f 1 Try it online! This script is brute force algorithm: converts ...


0

Keg, 37 bytes ?1&((⑻|⑩")(⑻|')⑹ ,)⑺⑺((⑻|⑩")(⑻|')⑺ ,) Try it online! I decided to try an interesting string shifting approach.


0

Fortran (GFortran), 79 bytes character(99)a read*,a k=len_trim(a) print('(a)'),(a(1:k-abs(i-k)),i=0,2*k) end Try it online! Fortran. Always good for string manipulation


0

GolfScript, 27 bytes .1/{0=1$?1$<}%n*.-1%@n+n\+\ Try it online!


0

TI-BASIC, 14 + 6 = 20 bytes This submission uses two programs, the main one and a helper program called prgmΘ. prgmΘ:Disp Ans+" "+Ans:prgmΘ ;main program Disp Ans+Ans+Ans ;helper program "prgmΘ" Input is a string stored in Ans.


1

GolfScript, 15 bytes ...n\." "\.n\.. Explanation At the beginning of the program, the input is put onto the stack. Each . copies the top of stack. Each n pushes a newline onto the stack. " " pushes a space. \ swaps the top two elements. At the end of the program, the stack is output to the standard output. Try it Online


0

Charcoal, 70 bytes F⪪↧S «Fι«F⪪”↶↖→∧gτ→|⮌!⧴KD✂‖5»⊞H⭆K↧ⅉ&$↥x-#↖x9|²λPe⁸” «P⊗№λκ↷¹»oM³→»⸿M³↓ Try it online! Link is to verbose version of code. Explanation: F⪪↧S « Split the lowercased input on spaces and loop over each word. Fι« Loop over each character. F⪪”↶↖→∧gτ→|⮌!⧴KD✂‖5»⊞H⭆K↧ⅉ&$↥x-#↖x9|²λPe⁸” « Split the compressed string fjmrwyz gnsvxz abcdefg ...


0

Burlesque, 20 bytes 3.*3.*{1 1}' D!)\[un Try it online! 3.* # Make a list of 3 instances {A A A} 3.* # Again {{A A A} {A A A} {A A A}} {1 1}' D! # Set value at 1,1 to a space {{A A A} {A A} {A A A}} )\[ # Concatenate each internal list {"AAA" "A A" "AAA"} un # Join array with newlines Burlesque, ...


0

R, 61 bytes r=")-*-*-*^_^*-*-*-(\n";cat(r,"| Welcome User! |\n",r,sep="") Try it online! Has a trailing newline. I couldn't see if that was approved or not, so I just rolled with it.


0

PowerShell, 68 bytes Write-Host ")-*-*-*^_^*-*-*-(`n| Welcome User! |`n)-*-*-*^_^*-*-*-(" Try it online!


0

Wren, 64 bytes Fn.new{"1| Welcome User! | 1".replace("1",")-*-*-*^_^*-*-*-( ")} Try it online! Explanation Fn.new{ // New anonymous function "1| Welcome User! | 1" // Create the string "| Welcome User! |" .replace("1",")-*-*-*^_^*-*-*-( ")} // Prepend & ...


2

Python 3, 31 bytes lambda s:3*s+f'\n{s} {s}\n'+3*s Try it online!


1

naz, 46 bytes 1x1f0m9a1a1o0x1r2x1v3o1f1v1o0m4a8m1o1v1o1f1v3o Strictly speaking, the above program outputs the exact byte stream required to make the square, though the top of the square will be misaligned given that the interpreter linked above always prepends output: to program output. Explanation (with 0x commands removed) 1x1f0m9a1a1o # Function 1 ...


1

05AB1E, 7 6 bytes using the canvas and compressed integers. 3IŽ9¦Λ Try it online!


Top 50 recent answers are included