New answers tagged

3

Python, 70 60 bytes print("rnbqkbnr","p"*8,*["."*8]*4,"P"*8,"RNBQKBNR",sep='\n') Also if someone could explain to me why this doesn't work, I'd appreciate it! map(print,["rnbqkbnr","p"*8,*["."*8]*4,"P"*8,"RNBQKBNR"])


2

Haskell :: 799 bytes Hi This is my first code-golf submission. It reads the initial grid from a text file. Is that permitted? Golfed: import Data.List pad i r=r++replicate(i-length r)' ' fl l = let w=maximum.map length$l h=length l in filter((/=' ').snd).zip[(x,y)|y<-[h,h-1..],x<-[1..w]].concat.map(pad w)$l sh b= let t=maximum.map(snd.fst)$b d=...


1

05AB1E, 11 bytes …_|_ĆƵм×Tä» Try it online! ä # split... … # three char string... _|_ # literal... Ć # concatenated with its first character... × # repeated... м # numeric literal... Ƶ # converted from base 255 to decimal plus 101... × # times... ä # into... ...


1

Jelly, 13 bytes 70:þ⁵“_|__”ṁY Try it online! The dyad given to þ doesn't matter so long as it outputs a scalar, so I chose : solely for aesthetic purposes. þ Take the rangifying outer product : by integer division 70 of 70 ⁵ and 10, “_|__”ṁ mold "_|__" like it, Y ...


0

Perl 5 -MList::Util=max -a, 64 bytes say$"x((length max@F)-y///c),y/0/ /r for@F=map{sprintf"%b",$_}@F Try it online!


1

Japt, 63 43 bytes Seeing as I apparently have a reputation for making Japt do things it shouldn't be able to do (continuous input, in this case), golfing from my my phone, and golfing with a feed of beer inside me, it's high time I combined all 3 of those things! ;$oninput=$@OqE¬ËoOx`Í*s.value` 1Ãú ò16 m¸· Test it (just start typing in the "Notes" ...


0

8086 machine code, MS-DOS .COM, 27 bytes Runnable in DOSBox. The only assumption about register starting values is AH = 0, which is true for most DOS isotopes. This, and the fact that only BIOS interrupts are used, means it can be run from a boot sector by changing the first instruction to mov ax, 3 (and the org of course) at the terrible, terrible cost of ...


0

Husk, 31 bytes *±¹↑→a¹¡oṁ§ṘȯJ' R2←o/3LgR'_`^3a Try it online! Doesn't really use the cantor set, just uses a replacement method (and an infinite list). Now, you may ask: why is an infinite list useful here? Here's an explanation: Explanation ¡oṁ§ṘȯJ' R2←o/3LgR'_`^3a a take abs(n) R'_`^3 repeat underscore n times(take ...


4

05AB1E, 43 bytes [Ž-∊13в.•:=r}ƒyp$γ•™“ŽØ¢© ÿ“.ªN._Ž9¦S.Λ,т.W What better time to answer a birthday related challenge than on your own birthday. ;) Outputs and rotates in a similar matter as the challenge description; sleeps for 100 ms in between iterations (could alternatively sleep for 255 ms, 256 ms, or 1 second for the same byte-count by replacing the т ...


2

Jelly, 21 bytes o7ŒT¤fØDV€d4Zị“.': ”Y Try it online! For the empty input, you can use either an empty string or no argument at all. Explanation o7ŒT¤fØDV€d4Zị“.': ”Y Main monadic or niladic link o Logical or (Python-like) 7ŒT¤ Current time in hh:mm:ss format f Filter ØD ...


2

APL (Dyalog Extended), 45 42 bytes ' .'':'[4 4⊤{×≢⍵:⍎¨⍵~':'⋄,⍉0 10⊤3↑3↓⎕TS}⍞] Try it online! A full program submission. -3 bytes from Bubbler. Very barely edges out Golfscript (Thanks, Bubbler!). Explanation ' .'':'[4 4⊤⍎¨{×≢⍵:⍵~':'⋄,⍉ 0 10⊤3↑3↓⎕TS}⍞] ⍞ string input {×≢⍵: if ...


0

Zsh, 60 bytes for ((;i<$1;))printf "|%$[i++]s\\\\\n"&&a=$a- (($1))&&<<<$a- Try it Online. Credit to the bash solution.


0

Japt -R, 14 bytes Could save at least 3 bytes with looser I/O requirements. õ@'*ùXÃê zVèÊÑ Try it 11 bytes Takes 0/1 as input for r/l and uses 1 instead of * oç mÄ ê zVÑ Try it õ@'*ùXÃê zVèÊÑ :Implicit input of integer U & string V õ :Range [1,U] @ :Map each X '* : Literal "*" ùX ...


1

Jelly, 15 bytes =”ro⁹ạŒḄ}⁶ẋp”*Y Try it online! If we can use any values instead of l and r, then this 11 byte program works for 1 being to the right and 0 to the left. If we can use any character rather than *, we can reduce the programs to 14 and 10 bytes How it works =”ro⁹ạŒḄ}⁶ẋp”*Y - Main link. Takes C on the left and n on the right ”r - &...


0

Japt -R, 11 bytes ;ó< £BôkX ¸ Try it or run all test cases ;ó< £BôkX ¸ :Implicit input of string ó< :Partition between characters where the first is < the second £ :Map each X ; B : Uppercase alphabet ô : Split at characters that return falsey (empty string) kX : When the ...


0

Forth (gforth), 53 bytes : f 1- 26. do dup i min spaces i 97 + emit cr loop ; Try it online! Pretty standard answer.


0

05AB1E, 9 bytes 27α‚A34SΛ Try it online. A golfed version of the existing 05AB1E answer in the new 05AB1E version is 9 bytes as well: Av<N‚ßyú, Try it online. Explanation: 27α # Take the absolute difference of 27 with the (implicit) input ‚ # Pair it to the (implicit) input A # Push the lowercase alphabet 34S # Push 34 ...


0

Japt -R, 9 bytes ;C¬ËùUm°E Try it ;C¬ËùUm°E :Implicit input of integer U ;C :Lowercase alphabet ¬ :Split Ë :Map each character at 0-based index E ù :Left pad with spaces to length Um : Minimum of U and °E : E incremented :Implicit output joined with newlines


0

Forth (gforth), 72 bytes : f dup 0 ?do i spaces 92 emit cr loop 1- for i spaces 47 emit cr next ; Try it online! there's probably a better way to do this.


0

Canvas, 6 bytes øZ[∔}r Try it here!


0

Bash, 53 bytes printf -v v %$1s;echo -e " ${v// /_} \n/$v\\\\\n|$v|" Try it online!


1

Forth (gforth), 97 89 bytes : e emit ; : b space dup 0 ?do 95 e loop cr 47 e dup spaces 92 e cr 124 e spaces 124 e ; Try it online! -8 bytes from Bubbler. Forth goes into infinite loops when given 0 for a do loop, since every loop must run atleast once. So a for loop with an if statement is used. Otherwise, this function is pretty straightforward.


2

PowerShell, 98 bytes $p=$args|%{$n=$_;31..0|?{($n-shr$_)%2}}|sort $args|%{$n=$_;-join($p[-1]..0|%{' *'[($n-shr$_)%2]})} Try it online! The script uses the fact that an integer contains no more than 32 bits. The first line calculates positions of the bits with 1. The second line renders a binary wall.


0

Canvas, 9 bytes H2┬!0∙ ╋∔ Try it here! Uses 1 as the display character.


0

Husk, 54 bytes mȯ¶↔T' §zoFz:,mömR' ∫Ẋo±+:_1†o!"/¦">0uf(Λ≥0∫)†?I←IPṘḋ2 Try it online! Does surprisingly well in this challenge. Explanation ḋ2 array [0,1] Ṙ repeat each \$n\$ times : 3 → [1,1,1,0,0,0] †?I←I decrement the zeroes f(Λ≥0∫) filter out the non-ranges using cumulative sum u uniquify §zoFz:, apply the following two functions a & b ...


1

k4, 9 bytes " *"@+2\: Takes input as a list of integers, outputs as a list of strings. 2\: convert to base 2 representation + transpose result " *"@ replace 0's with and 1's with *


0

Japt, 7 bytes Outputs an array of lines, using 1 for the bricks ®¤r0SÃù Try it (footer replaces 1s with *s) or run all test cases ®¤r0SÃù :Implicit input of array ® :Map ¤ : To binary string r0 : Replace 0s with S : Space à :End map ù :Left pad each with spaces to the length of the longest


0

Husk, 41 bytes !→⁰¡(↔§z+ömR' h∫mLtΘ`:"x"ṁȯe"x"Ṙ3f≠' );"x Try it online! Creates an infinite list of graphs and indexes into them, cause why not.


0

Canvas, 54 bytes H┐“)4╪xω╷┘IQ+azQ┴¾4*↔⌐∔v│↶++z2;e\1p9H+m}`1L²‟19┤n;83╋╋ Try it here!


0

Husk, 23 bytes ´Ṫȯ!"□ "¬nmḋ†%2mB3ŀ`^3← Try it online! Translation of Jonathan Allan's program. uses the '□' character.


1

Canvas, 14 bytes L╷rH ×⁸;*∔}↔↕┼ Try it here! Explanation L|rH ×⁸;*∔}↔↕┼ L length of input |r decrement, make range [0..n-1] H create an empty art object, start a loop with i × repeat space i times ⁸; swap with the input * join input with i spaces ∔ add to the bottom of ...


3

C++ (gcc), 257 ... 254 248 - 32 - 10 = 212 chars #include<bits/stdc++.h> namespace std{int f(){string a,b;for(int i:{1,3}){getline(cin,a={});b.resize(max(a.size()/2,b.size()));for(int j=a.size();j--;)b[j/2]+=(a[j]>32)<<i-j%2;}for(int i:b)cout.write(" ▝▘▀▗▐▚▜▖▞▌▛▄▟▙█"+i*3,3);cout<<endl;cin&&f();}} Try it online! ...


2

Japt -R, 32 31 30 32 31 bytes Really enjoyed this one but not entirely happy with the final result, especially after having to add 2 bytes to fix a bug. Still determined to get it down under 30 byes, though. Uses n for * and " for -. Q¸ï¡P=yÈrSùÍSúÍêUËçÍÃúÃâ)c ÅúQ Try it (footer replaces characters used with * & -) or run all test cases Q¸ï¡P=...


2

APL (Dyalog Unicode), 53 - 10 = 45 chars ' ▗▖▄▝▐▞▟▘▚▌▙▀▜▛█'[{2⊥∊⍵}⌺(2 2⍴2)⊢↑{2|≢⍵:⍵,0⋄⍵}' '≠⎕] Try it online! -10 bytes for an explanation? Count me in! Takes input as a list of lines from STDIN. Explanation ' ▗▖▄▝▐▞▟▘▚▌▙▀▜▛█'[{2⊥∊⍵}⌺(2 2⍴2)⊢↑{2|≢⍵:⍵,0⋄⍵}' '≠⎕] ⎕ take input ...


2

Julia 1.0, 100 90 bytes s->(l=length(s)-2;[' '^(-~l*(l-j))*prod(s[abs(i)+1]*' '^j for i=~l:l+1) for j=abs.(-l:l)]) Try it online! -10 bytes thanks to @KevinCruijssen


0

05AB1E, 14 bytes ¦ε\RðN×ýû}Rû.c Input as a list of characters. Try it online or verify all test cases. 14 bytes alternative: ā¨RjJíðδÜ€ûû.c Also takes a list of characters as input. Try it online or verify all test cases. Explanation: ¦ # Remove the first item of the (implicit) input-list # (could have removed the last as ...


0

Canvas, 22 bytes A;╷{┐⤢l;L┘¹Zj@┘┘*+}╶[⤢ Try it here!


0

Canvas, 7 bytes ╶╶90┤÷↷ Try it here! basically cheating


1

Japt -R, 15 bytes ÊÆÔ¬qXç)êÃÔÅê û Try it ÊÆÔ¬qXç)êÃÔÅê û :Implicit input of string Ê :Length Æ :Map each X in the range [0,length) Ô : Reverse U ¬ : Split q : Join with Xç : X spaces ) : End join ê : ...


1

Canvas, 24 bytes H(¹)*!∔}─L╷ ×;+ ∔:↔∔⤢╶×↔ Try it here!


1

Python 2, 58 bytes lambda l:[s.index('_')+1for s in zip(*l[-2::-1])if'_'in s] Try it online! Taking input as list of strings.


0

Jelly, 9 bytes ṖZ=”_UT€F Try it online! Unfortunately, Jonathan Allan's answer is still shorter, as I assume input is a list of lines, so don't count the Ỵ. However, I reckon this is an interesting enough approach to post How it works ṖZ=”_UT€F - Main link. Takes a list of lines L on the left Ṗ - Remove the last line Z - Transpose =”_ -...


0

Japt, 9 bytes Takes input as an array of lines. Õ®x2 èSÃf Try it (header splits input string to array) or run all test cases Õ®x2 èSÃf :Implicit input of array Õ :Transpose ® :Map x2 : Trim left è : Count S : Spaces à :End map f :Filter


0

Japt -h, 20 bytes Ñ ÆP=Õû"0*+"gX=z)XÑÄ Try it or run all test cases Ñ ÆP=Õû"0*+"gX=z)XÑÄ :Implicit input of integer U Ñ :U*2 Æ :Map each X in the range [0,U*2) P= : Reassign to P (initially the empty string) Õ : Transpose P û ...


0

Canvas, 52 bytes ‽“pbn@;║L↶F{8ø⇵ohUY÷²[L┘↗HZ4vy)Cg⁰‟t}$¶|∙---¶~~~─∔r× Try it here!


0

Canvas, 15 bytes H0*+@¹2×╷:*;22╋ Try it here! Can probably be shortened further. Explanation H0*+@¹2×|:*;22╋ H push an empty art object, start a loop using input 0*+ string "0*+" @ get the nth element, circularly <-----------+ ¹ loop iteration | 2× ...


0

Canvas, 14 bytes #*@H╶:*l⁸∔½:╋} Try it here!


1

Canvas, 13 bytes HH/n}!╬+}⤢r!║ Try it here!


3

Husk, 72 bytes mṙ1₁Fz+m(₁TT' Ṡ:→S:öR'-→▲mL)mS+ȯRø≠▲mLe³¹LJ;n³¹mo-n³¹e Ṡz:(`:'+:'+R'|-2L Try it online! Husk does not support arrays of multiple types, so the arguments must be string arrays. I am not sure whether I want to explain this monstrosity. Due to it's sheer size, it takes about 28 secs(due to type inference) for the first test case mentioned. ...


1

Canvas, 7 bytes H\║n↔}↕ Try it here! I guess Canvas is now the ideal language for this challenge.


Top 50 recent answers are included