# It was just a bug

Inspired by the bugged output in @Carcigenicate's Clojure answer for the Print this diamond challenge.

## Print this exact text:

1        2        3        4        5        6        7        8        9        0
1       2       3       4       5       6       7       8       9       0
1      2      3      4      5      6      7      8      9      0
1     2     3     4     5     6     7     8     9     0
1    2    3    4    5    6    7    8    9    0
1   2   3   4   5   6   7   8   9   0
1  2  3  4  5  6  7  8  9  0
1 2 3 4 5 6 7 8 9 0
1234567890
1 2 3 4 5 6 7 8 9 0
1  2  3  4  5  6  7  8  9  0
1   2   3   4   5   6   7   8   9   0
1    2    3    4    5    6    7    8    9    0
1     2     3     4     5     6     7     8     9     0
1      2      3      4      5      6      7      8      9      0
1       2       3       4       5       6       7       8       9       0
1        2        3        4        5        6        7        8        9        0


(From the middle outward in both directions, each digit is separated by one more space than the previous line.)

## Challenge rules:

• There will be no input (or an empty unused input).
• Trailing spaces are optional.
• A single trailing new-line is optional.
• Leading spaces or new-lines are not allowed.
• Returning a string-array isn't allowed. You should either output the text, or have a function which returns a single string with correct result.

## General rules:

• This is , so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
• Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
• Default Loopholes are forbidden.
• Is outputting an array of strings - 1 string per line - allowed? – Shaggy Jul 3 '17 at 9:37
• @Shaggy Sorry, in this case it should either return a single string with new-lines, or output the result. I've added this as rule to the challenge. – Kevin Cruijssen Jul 3 '17 at 11:06
• No worries, Kevin; was just chancing my arm to see if I could save myself a couple of bytes. – Shaggy Jul 3 '17 at 11:09
• @Shaggy Hehe. What other reason would we have to ask question in a code-golf challenge, besides having the purpose of saving those few bytes? ;) – Kevin Cruijssen Jul 3 '17 at 11:23
• Ha, that's awesome. I was wondering why that answer suddenly got so much attention. Thanks! – Carcigenicate Jul 3 '17 at 19:41

# PowerShell, 30 bytes

8..0+1..8|%{1..9+0-join' '*$_}  Try it online! Constructs a range of 8,7,6...2,1,0,1,2...8 then loops through each number. Inside the loop we construct a range of 1..9 concatenated with 0 then -join the numbers in the range together with the appropriate number of spaces. Each string is left on the pipeline, and output is implicit at program completion. • Nice answer! Powershell suddenly feels more golfy :) – Mr. Xcoder Aug 29 '17 at 19:56 ## JavaScript, 67 Bytes f=(i=8)=>i+9?[...1234567890 ].join(''.padEnd(i<0?-i:i))+f(i-1):''  f=(i=8)=>i+9?[...1234567890 ].join(''.padEnd(i<0?-i:i))+f(i-1):'' console.log(f()) ## LOGO, 58 57 bytes for[j 8 -8][repeat 9[type # repeat abs :j[type "\ ]]pr 0]  This should be run on new versions of FMSLogo (link above), where # is repcount in repeat loops. That is a new feature in FMSLogo, which seems to be undocumented. # bash (and shell utils), 69 bytes for i in seq 9 -1 1;seq 2 9;do seq -f%-$i.f 9|tr -d \\n;echo 0;done


# QBIC, 36 32 bytes

[-8,8|?[|?!b%z$';space$(abs(a));


## Explanation

[-8,8|     FOR a = -8; a <= 8; a++      Sets upthe number of lines
?          Kick off each line with a \n
[|         FOR b = 1; b <= 10; b++      Loop over each digit: default behaviour for a no-arg FOR declaration
?          PRINT
!   $a strng cast (suppresses QBasic's tendency to space out numbers) b%z of b modulo 10 (z is 10 in QBIC) ' Then take the next bit of code as literal QBasic ; Suppress newlines and tabs space$    Add x spaces to the output, where X is
(abs(a))  The absolute line number
;         And suppress all newlines and tabs after this too
A closing  to this code literal is auto added by QBIC at EOF
Two closing NEXT statements are also auto-added.


## Sample output

Just because I really like the pattern. Note that this took some fiddling in QBasic because the usual terminal output is limited to 80 chars and it wraps.

1        2        3        4        5        6        7        8        9        0
1       2       3       4       5       6       7       8       9       0
1      2      3      4      5      6      7      8      9      0
1     2     3     4     5     6     7     8     9     0
1    2    3    4    5    6    7    8    9    0
1   2   3   4   5   6   7   8   9   0
1  2  3  4  5  6  7  8  9  0
1 2 3 4 5 6 7 8 9 0
1234567890
1 2 3 4 5 6 7 8 9 0
1  2  3  4  5  6  7  8  9  0
1   2   3   4   5   6   7   8   9   0
1    2    3    4    5    6    7    8    9    0
1     2     3     4     5     6     7     8     9     0
1      2      3      4      5      6      7      8      9      0
1       2       3       4       5       6       7       8       9       0
1        2        3        4        5        6        7        8        9        0


# perl 5: 43, 39, 31 bytes

Needs -E flag (which is free per our consensus).

map{$,=$"x abs;say 1..9,0}-8..8


Usage:

perl -E 'map{$,=$"x abs;say 1..9,0}-8..8'


• That's nice! -E flag is free per our consensus. Also, you probably wanted -8..8 instead of -8..9. And you can save a few bytes by playing with $, instead of $": map{$,=$"x abs;say 1..9,0}-8..8 (31 bytes). – Dada Jul 3 '17 at 9:11
• @Dada:You're right, thank you, 4 bytes saved! – Toto Jul 3 '17 at 9:16
• You don't even need to declare @l: just use say 1..9,0 :) – Dada Jul 3 '17 at 9:17

# Common Lisp, 85 bytes

(dotimes(i 17)(format t(format()"~~{~~,,~aa~~}
"(abs(- i 8)))'(1 2 3 4 5 6 7 8 9 0)))


Try it online!

format “magic” of Common Lisp:

(dotimes (i 17)                     ; for i from 0 to 16
(format t                         ; print with a format string generated from the next call
(format ()                ; with nil as parameter generates a string instead of printing
"~~{~~,,~aa~~}
"                                   ; generate the format string "~{~,,na~}~%" with n given
(abs(- i 8)))     ;     by the value of abs(i-8) (number of spaces)
'(1 2 3 4 5 6 7 8 9 0)))  ; the data to be printed for each line


## PHP, 76 Bytes

Update: Thanks to Soaku for the addition.

for($i=-9;$i++<8;)echo join(str_repeat(' ',abs($i)),range(1,9)+[9=>0])." ";  Try it online ! ## PHP, 88, 86, 80 Thanks to Caird for suggesting the golfing tips. for($i=-9;$i++<8;)echo join(str_repeat(' ',abs($i)),[1,2,3,4,5,6,7,8,9,0])."\r";


You can try it here!

• Welcome to the site, and be sure to check these tips for golfing in PHP! – caird coinheringaahing Apr 5 '18 at 10:16
• Sorry so late, but I golfed it down to 76 bytes – RedClover Jun 15 '18 at 19:37
• str_pad("",abs($i)) is four bytes shorter than str_repeat(' ',abs($i)). – Titus Oct 28 '18 at 9:56

## Perl 6, 43 37 35 bytes

Originally, I came to:

map({say join " "x abs($_-8),1..9,0},0..16)  The say function in perl 6 automatically adds a newline, and it's map works a bit different from perl 5, requiring less parens due to it's more list based approach. Try it online Fortunately, Jo King showed how to whittle it down further to 35 bytes: {say join " "x.abs,1..9,0}for ^17-8  Try it online • 0..16 => ^17 – Jo King Jul 26 '18 at 1:08 • Or you can change to a list and use the list repetition operator for 37 bytes – Jo King Jul 26 '18 at 1:11 • Thanks, there's always more to learn :) Interestingly, the code that runs on TIO perl6 does not run with rakudo, unless I change$++ to $_++ – whofferbert Jul 26 '18 at 1:20 • Huh. Well, here's 35 byter that uses a for loop – Jo King Jul 26 '18 at 1:24 • Ah, I found the problem with$++ vs $_++, perl6 version 2013.12 built on parrot 5.9.0 revision 0, vs perl6 version 2015.11 built on MoarVM version 2015.11, where it behaves as on TIO. – whofferbert Jul 26 '18 at 1:37 # R, 51 bytes for(i in abs(-8:8))cat(1:9,0," ",sep=strrep(" ",i))  Try it online! Managed to find some more bytes thanks to JayCe's suggestion in the comments. # C, 135 128 characters ### -7 characters thanks to kevin cruijssen #define p printf i=1,j,h=9,k;main(){for(;++i<22;i<10?h--:h++,p("\n"))for(j=0;++j<11;)for(p(j==10?"0":"%d",j),k=1;k++<h;)p(" ");}  Try it online! ### Fun bonus: On my first compile I got the logic backwards and ended up with the output in reverse i=1,j,k,h=9;main(){for(;i++<20;){for(j=0;j++<10;){printf(j==10?"0":"%d",j);for(k=1;k++<10-h;){printf(" ");}}i<11?h--:h++;printf("\n");}}  Edit: removed missed whitespace # J, 25 22 bytes (1 j.|i:8)#"{1|.Num_j_  Try it online! # Vyxalj, 15 bytes 8N8ṡȧƛð$ẋ9ʀ1Ǔ$j  Try it Online! -1 byte thanks to Aaron Miller 8N -8 8 8 ṡ inclusive range; -8, -7, ..., 7, 8 ȧ abs; 8, 7, ..., 1, 0, 1, ..., 7, 8 ƛ--------- for each ð$            push space and swap it underneath
ẋ           repeat the space N times
9ʀ         [0, 1, ..., 8, 9]
1Ǔ       rotate left once
$j swap and join j (flag) join on newlines  # V, 18 bytes ¬19á08ñÄÓä/& YGpH  Try it online! # q/kdb+, 37 bytes Solution: -1" "{raze(1_11#.Q.n),\:y#x}'8-(!)17;  Example: q)-1" "{raze(1_11#.Q.n),\:y#x}'8-(!)17; 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1234567890 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0  Explanation: q is evaluation right-to-left. Here we are taking the range of -8..0..8, and joining that many spaces with the list "1234567890". We then use -1 to print out to stdout (rather than returning the list of strings). -1 " "{raze (1_11#.Q.n),\:y#x}'8 - til 17; / ungolfed solution til 17 / range of 0..16 8 - / take 8 from each value, gives -8..0..8 " "{ }' / each left/right, passes in " " and then -8, -7, etc.. y#x / take from list " ", note: negatives take from 'back' of list ,\: / \: is 'each left', , means concatenate with, so take each left and concatenate with the right (1_11#.Q.n) / 'the left'. .Q.n is range 0-9 as a string, take 11 to get 0123..90, then drop the first raze / reduce down output list into a single string -1 ; / print to stdout and swallow return value (-1)  Notes: Doing (1_11#.Q.n) is 1 byte shorter than the much more straightforward "1234567890"... but as .Q.n returns "0123456789" some manipulation is required. # Ruby 2.4, 40 bytes -8.upto 8{|i|puts [*1..9,0]*(' '*i.abs)}  # Ruby (lower than 2.4), 41 bytes -8.upto(8){|i|puts [*1..9,0]*(' '*i.abs)}  Try it online! Swift 3.1, 186 182 bytes func f(_ n:Int=0,_ u:Bool=true){let p={if n<8{f(n+1,u)}};let q={print((1...9).map{String($0)+String(repeating:" ",count:n)}.joined()+"0")};if u{q();p()}else{p();q()}};f(1,false);f()


Explanation

func f(_ n:Int=0,_ u:Bool=true){          function (recursive) that does
all the heavy-lifting =)
n - number of spaces,
u - go "up" or "down
let p={if n<8 {f(n+1,u)}}                 closure that runs f on higher step if can
let q={                                   closure which does the printing
print((1...9).map{                        print closed range of number mapped...
String($0)+String(repeating:" ",count:n) ...making String from each number in range and appending n spaces to it .joined()+"0") join all "1 "-like strings and append "0" if u{q();p()} if go "up" - then call f before printing else{p();q()} if go "down - the other way f(1,false);f() run "up" then "down"  Removed some silly spaces. Thanx to Kevin Cruijssen • I feel there is a room for an improvement, though – Sergii Martynenko Jr Jul 4 '17 at 13:50 • I've never programmed in Swift, so perhaps I'm saying something stupid here, but is it possible to remove some of those spaces? Like the one here: n<8 {f(n+1; here: count:n) }; here: p()} else{p(); and/or here q()}}; f(1,false? – Kevin Cruijssen Jul 4 '17 at 14:24 • 171 bytes – Tamás Sengel Apr 5 '18 at 16:52 # PHP, 71 bytes while($y<17)echo chunk_split(1234567890,1,str_pad("",abs($y++-8)))," ";  Run with -nr or test it online. • Inspired by your solution, I got my solution down to 66: while($i<17)echo implode(str_pad('',abs($i++-8)),range(1,9))."\n"; – jstnthms Jul 20 '17 at 17:48 • Oops! Looks like I made an incorrect assumption about the output. I thought it was 123456789 – jstnthms Jul 20 '17 at 17:51 # Bubblegum, 140 bytes :P 0000000: ad92 510e c230 0c43 ff39 0547 802c f3bc ..Q..0.C.9.G.,.. 0000010: fb5f 8c10 c5d1 5a09 10b0 7d59 b1fd b4b6 ._....Z...}Y.... 0000020: b95f eb33 8945 c225 5609 486c 1294 d825 ._.3.E.%V.Hl...% 0000030: 6e17 216d 02fa 84c3 04a3 5033 c906 8e0f n.!m......P3.... 0000040: 140c 0c8a 3000 ec50 f743 1987 2abb d83d ....0..P.C..*..= 0000050: eb96 7707 dda0 f215 b70a 7b45 5141 66ac ..w.......{EQAf. 0000060: 5296 19cf 04d2 67ba 4fd3 c2f2 3010 63c6 R.....g.O...0.c. 0000070: 3066 b6f8 8a8d fb0b fb0d eff3 2f7d 77ce 0f........../}w. 0000080: 1faf f3df 773c 7fa5 cedf f707 ....w<......  Try it online! Do I get brownie points for having ._. two times in the dump? • 131 bytes – ovs Jul 20 '17 at 18:05 • How did I get out-golfed in Bubblegum? o0 What compression method did you use? – totallyhuman Jul 20 '17 at 18:07 • I used zopfli to generate a DEFLATE stream. I got to 130 bytes with 222 iterations. – ovs Jul 20 '17 at 18:09 • For some reason the byte count went up with more then 314 iterations. zopfli link – ovs Jul 20 '17 at 18:10 # MATL, 21 bytes -9Zv"l4Y29YS10:q@*Q(c  Try it online! Explanation: -9Zv % Generates [9 ... 2, 1, 2, ... 9]. " % Iterate over this vector. ( % Assignment indexing. Places elements B at positions C in existing vector A. l % A: Dummy vector with numeric [1] in it. Is always overwritten by char '1'. 4Y29YS % B: '0':'9', circularly shifted 9 positions to get '1':'9','0' 10:q@*Q % C: Equally spaced indexing vector, spacing based on loop variable @. c % Convert to char, because A was numeric.  Golfing done: -9Zv --> built-in, instead of -8:8|Q or even 8:PQ9:h| 10:q@*Q --> 2 bytes shorter than l@@10*3$:
l ... c  -->  1 byte shorter than 'x' (char dummy vector A)


I have attempted to get rid of the 9YS by doing the circular shift in the indexing, but this increased the byte count (10t:qwX\q@*Q instead of 9YS10:q@*Q). However, some interesting patterns were obtained in the process: Try it online!, Try it online!.

# Perl 5, 31 29 bytes

$,=$"x abs,say 1..9,0for-8..8


Try it online!

# Zsh, 6157 49 bytes

-4, -8 thanks to @pxeger

for 1 ({9..1} {2..9}){printf %-$1s {1..9} 0;echo}  Similar to the Spaceship Maw! solution. • – pxeger Jan 25 at 19:26 • wow. i didn't know you could set $1 and $2 and use $@ like that. – roblogic Mar 27 at 14:20
• – pxeger Mar 27 at 15:27

# Cheddar, 42 bytes

-8|>8=>n->print(1|>9+[0]).join(abs(n)*' ')


Try it online!

# Stacked, 33 bytes

9:>' '*[9~>\#]"!:8~>#rev\,$out"!  Try it online! ## Explanation 9:>' '*[9~>\#]"!:8~>#rev\,$out"!
9:>                                 range from 0 to 9 (right-exclusive)
' '*                             vectorized repetition of the space
[      ]"!                   on each repetition:
9~>                           generate a range from 1 to 9
\#                        and join it by that repetition
:8~>#              copy all but the first element
rev           reverse it
\,         swap then concatenate
$out"! output each  # ///, 251 bytes /B/' //A/!!//@/" //?/\/\///>/ ?=/0 1?</ 2 3 4 5 6 7 8 9 ?;/!2!3!4!5!6!7!8!9!?:/'2'3'4'5'6'7'8'9'?-/="2"3"4"5"6"7"8"9"=?,/@2@3@4@5@6@7@8@9@?'/!"?&/=>2>3>4>5>6>7>8>9>=?%/=A2A3A4A5A6A7A8A9A=?#/1B2B3B4B5B6B7B8B9B0?"/! ?!/> /# 1:%,-;&<=23456789=<&;-,%:0 #  Considerably long, but /// has no real way of modifying data elegantly. # Delphi / Pascal 137 Bytes* program x;{$APPTYPE CONSOLE}var i,j: Integer;begin for i:=-8 to 8do begin write(#10,1); for j:=2 to 10do Write(j mod 10:Abs(i)+1);end;end.


*The {$APPTYPE CONSOLE} is a compiler directive that can be removed for pure Pascal. or if compiled with the Delphi command line compiler using the -cc switch to give 119 bytes. Without it you get a runtime error as it tries to print to a non existent console. # [Java 7], 137 132 bytes Saved 3 bytes thanx to Kevin Cruijssen and 2 more thanx to TheLethalCoder void a(){int i,j,k;for(i=-8;i<9;i++){String a="";for(j=1;j<11;j++){a+=j%10;for(k=0;k<(i<0?-i:i);k++)a+=" ";}System.out.println(a);}}   void a(){for(int i=-8;i<9;i++){String a="";for(int j=1;j<11;j++){a+=j%10;for(int k=0;k<Math.abs(i);k++){a+=" ";}}System.out.println(a);}}  Ungolfed:  void a(){ int i,j,k; for(i=-8;i<9;i++){ String a=""; for(j=1;j<11;j++){ a+=j%10; for(k=0;k<(i<0?-i:i);k++)a+=" "; } System.out.println(a); } }  • Declare i, j, and k in one place to save bytes (I'm sure you go do this in Java). Use Java 8 and compile to an anonymous method. I think int i=-9;++i<9;i should work and similar for j and k. I'm not sure if Math needs qualifying but I don't know Java well enough to say for sure. I think you can remove the braces from the k loop as well. – TheLethalCoder Jul 5 '17 at 8:29 • Also it might be cheaper, especially when compiling to a lambda, to return the results as a string. – TheLethalCoder Jul 5 '17 at 8:31 • Welcome to PPCG! There is already a shorter Java answer posted, but that doesn't matter because it uses a different approach. But, you can still shorten your code a bit like this: void a(){for(int i=-8,j,k;i<9;i++){String a="";for(j=1;j<11;)for(a+=j++%10,k=0;k++<(i<0?-i:i);)a+=" ";System.out.println(a);}}. (I've put some things inside the for-loop to get rid of the brackets; I've removed the two int by adding ,j,k in the first loop; and I've changed Math.abs(i) to (i<0?-i:i). It might also be useful to read Tips for golfing in Java. :) Enjoy your stay. – Kevin Cruijssen Jul 5 '17 at 8:33 # C#, 131 bytes My first participation for(int i=8;i>-9;i--){for(int n=1;n<=10;n++){Console.Write((n==10?"0":n.ToString())+new String(' ',Math.Abs(i))+(n==10?"\n":""));}}  More easy reading version for (int i = 8; i > -9; i--) { for (int n = 1; n <= 10; n++) { Console.Write((n==10 ? "0" : n.ToString()) + new String(' ', Math.Abs(i)) + (n == 10 ? "\n" : "")); } }  • Welcome to PPCG.SE! A nice first post though by default, you should supply a full program or function, not just a snippet like you have here. See this meta post for more. I would also recommend you have a look at Try it Online which lets you run your code online and share it with others. It can also format your answers for you to post here. – Notts90 supports Monica Jul 6 '17 at 10:47 • Welcome to PPCG! In addition to what @Notts90 said, I can also recommend reading Tips for golfing in C# and Tips for golfing in <all languages>. Some things you can golf is removing the brackets and int; change the condition to remove the =; and change the Math.abs, like this: o=>{for(int i=8,n;i>-9;i--)for(n=1;n<11;n++)Console.Write((n>9?0:n)+new String(' ',i<0?-i:i)+(n>9?"\n":""));} (where o=> is an unused parameter). Try it here. Again welcome, and enjoy your stay. :) – Kevin Cruijssen Jul 6 '17 at 11:03 • Oh, and one more thing after my previous golfed version: o=>{for(int i=8,n;i>-9;i--)for(n=1;n<11;)Console.Write((n>9?0:n)+new String(' ',i<0?-i:i)+(n++>9?"\n":""));} (the n++ is removed and ++ is added to the last n. Try it here. So 108 bytes in total. – Kevin Cruijssen Jul 6 '17 at 11:47 • Thanks for the comments Notts90 and Kevin, I will look at your code this evening :) – Matthieu Charbonnier Jul 6 '17 at 12:21 # tcl, 112 Very naïve: proc x n\ s {time {puts [join {1 2 3 4 5 6 7 8 9 0} [format %[incr n$s]s \ ]]} 9}
x 10 -1
puts 1234567890
x 0 1


# /// (Slashes), 377 374 bytes

/a/1_//b/2_//c/3_//d/4_//e/5_//f/6_//g/7_//h/8_//i/9_//z/0
//./  //-/. //_/../a_b_c_d_e_f_g_h_i_za-b-c-d-e-f-g-h-i-za.b.c.d.e.f.g.h.i.za b c d e f g h i zabcdefghiz1-2-3-4-5-6-7-8-9-z1.2.3.4.5.6.7.8.9.z1 2 3 4 5 6 7 8 9 z123456789z1 2 3 4 5 6 7 8 9 z1.2.3.4.5.6.7.h.9.z1-2-3-4-5-6-7-8-9-zabcdefghiza b c d e f g h i za.b.c.d.e.f.g.h.i.za-b-c-d-e-f-g-h-i-za_b_c_d_e_f_g_h_i_0


Try it online!

## Explanation

The original output was initially compressed by doing the following replacements:

•      (4 spaces)_
•     (3 spaces)-
•    (2 spaces).

In a second step, 1_ was replaced by a, 2_ by b and so on. Finally, those mappings were inverted and prepended to the code.

/./  //-/   //_/    //_/..//-/. //./  /
• /./ //-/ //_/ / can be /_/..//-/. //./ /. Imagine the spaces being correct because Markdown doesn't like multiple spaces in inline code blocks >:( – CalculatorFeline Jul 9 '17 at 21:17