| Bytes | Lang | Time | Link |
|---|---|---|---|
| 083 | Swift 6 | 230723T203843Z | macOSist |
| 076 | Tcl | 170706T152605Z | sergiol |
| 016 | Vyxal 3 | 250417T083225Z | Themooni |
| 067 | AWK | 250313T191248Z | xrs |
| 069 | Nim | 250312T102520Z | janAkali |
| 098 | Tcl | 181216T194457Z | david |
| 024 | K ngn/k | 240804T163008Z | coltim |
| 066 | Regenerate | 240722T224259Z | DLosc |
| 010 | Vyxal Ṁjr | 240222T165730Z | pacman25 |
| 012 | Vyxal 3 j | 240222T165131Z | pacman25 |
| 076 | Scala | 230727T122644Z | t9dupuy |
| 048 | Zsh | 201212T104913Z | roblogic |
| 011 | Thunno 2 N | 230722T050630Z | The Thon |
| 011 | Vyxal j | 220707T213735Z | naffetS |
| 069 | Dash* | 210907T084456Z | bxm |
| 103 | Java JDK | 210904T140633Z | 0xff |
| 011 | MathGolf | 181005T145630Z | maxb |
| 045 | jq nr | 210904T104912Z | ovs |
| 074 | Excel | 210904T142934Z | Axuary |
| 2606 | Deadfish~ | 210904T123714Z | ovs |
| 015 | Vyxal j | 210511T065439Z | hyperneu |
| 072 | BRASCA | 210514T173834Z | RezNesX |
| 016 | Pip l | 180907T205446Z | DLosc |
| 012 | Stax | 210511T080228Z | Razetime |
| 2959 | Deadfish~ | 210328T060938Z | emanresu |
| 029 | Perl 5 | 170731T200809Z | Xcali |
| 022 | J | 180405T091106Z | FrownyFr |
| 124 | Rockstar | 200911T114620Z | Shaggy |
| 027 | Pushy | 181216T183848Z | FlipTack |
| 013 | Japt R | 170703T085739Z | Shaggy |
| 244 | /// | 181028T090552Z | Erik the |
| 098 | Java 11 JDK | 170703T090402Z | Olivier |
| 239 | Sisi | 180907T214605Z | DLosc |
| 128 | C | 180727T001544Z | J.Barber |
| 126 | Elixir | 180726T161617Z | Delioth |
| 071 | JavaScript | 180726T153955Z | MattH |
| 066 | QBasic | 180726T151515Z | Taylor R |
| 051 | R | 180726T143008Z | Giuseppe |
| 035 | Perl 6 | 180726T010354Z | whofferb |
| 058 | VBA | 180725T163010Z | Taylor R |
| 076 | PHP | 180405T100734Z | Boian Iv |
| 015 | Canvas | 180405T164050Z | hakr14 |
| 209 | brainfuck | 180405T162058Z | X1M4L |
| 013 | Pyth | 170703T075509Z | Leaky Nu |
| 085 | Lua | 180405T072330Z | dragonit |
| 012 | SOGL V0.12 | 171028T205957Z | dzaima |
| 030 | PowerShell | 170829T194200Z | AdmBorkB |
| 100 | Sink | 170708T023453Z | Julian Z |
| 2622 | Cubically | 170731T191914Z | MD XF |
| 021 | MATL | 170706T104138Z | Sanchise |
| 140 | Bubblegum | 170717T182544Z | totallyh |
| 055 | Python 2 | 170703T072751Z | Mr. Xcod |
| 374 | /// Slashes | 170706T165304Z | Cedric R |
| 054 | Python 3 | 170706T020828Z | ShadowRa |
| 108 | R | 170703T142907Z | Probel |
| 022 | APL Dyalog | 170703T073024Z | Adá |
| 131 | C# | 170706T100337Z | Matthieu |
| 068 | JavaScriptES2017 | 170703T080201Z | Tushar |
| 099 | Clojure | 170703T200759Z | Carcigen |
| 085 | Common Lisp | 170705T062108Z | Renzo |
| 069 | PHP | 170703T103327Z | Jör |
| 132 | [Java 7] | 170705T082617Z | Java Gon |
| 071 | PHP | 170705T074256Z | Titus |
| 182 | Swift 3.1 | 170704T134942Z | Sergii M |
| 040 | Ruby 2.4 | 170705T070359Z | G B |
| 037 | q/kdb+ | 170705T062912Z | mkst |
| 137 | Delphi / Pascal 137 Bytes* | 170705T044322Z | Gerry Co |
| nan | C64 ASM | 170704T182301Z | Jupp3 |
| 084 | Python | 170704T182838Z | Евгений |
| nan | TSQL 145 | 170703T185439Z | Reversed |
| 148 | TSQL | 170703T085519Z | Jan Droz |
| 031 | perl 5 | 170703T083653Z | Toto |
| 076 | C gcc | 170704T001636Z | anatolyg |
| 251 | /// | 170703T210306Z | Conor O& |
| 033 | Stacked | 170703T202617Z | Conor O& |
| 021 | Husk | 170703T173126Z | Zgarb |
| 035 | Vim | 170703T170038Z | DJMcMayh |
| 032 | QBIC | 170703T154820Z | steenber |
| 055 | Haskell | 170703T085845Z | bartavel |
| 053 | Vim | 170703T155555Z | biowease |
| 069 | bash and shell utils | 170703T150411Z | Thomas |
| 018 | V | 170703T142947Z | DJMcMayh |
| 072 | Python 2 | 170703T133532Z | ovs |
| 013 | 05AB1E | 170703T090336Z | Emigna |
| 014 | SOGL V0.12 | 170703T110137Z | dzaima |
| 163 | Batch | 170703T105733Z | Neil |
| 018 | Charcoal | 170703T103001Z | Neil |
| 097 | C | 170703T100618Z | tomsmedi |
| 057 | LOGO | 170703T095924Z | user2027 |
| 021 | CJam | 170703T093228Z | Martin E |
| 163 | Java 8 | 170703T082250Z | Alex Fer |
| 067 | JavaScript | 170703T084447Z | Craig Ay |
| 018 | Charcoal | 170703T073038Z | Charlie |
| 042 | Cheddar | 170703T081143Z | Leaky Nu |
| 092 | Mathematica | 170703T072514Z | ZaMoC |
| 028 | Brachylog | 170703T072835Z | Fatalize |
| 015 | Jelly | 170703T072646Z | Leaky Nu |
Swift 6, 106 83 bytes
for i in -8...8{print(""+(1...10).flatMap{"\($0%10)"+{String.init}()(" ",abs(i))})}
Tcl, 76 bytes
set n -10
time {puts [join {1 2 3 4 5 6 7 8 9 0} [format %[incr n]s ""]]} 19
Vyxal 3, 16 bytes
①ʀƛkd↺$␣×j}æᐐpf”
①ʀƛkd↺$␣×j}æᐐpf”
①ʀƛ } # map over 0..9 (inclusive)
kd # digits 0-9
↺ # rotate once to get 0 at the end
j # join by
␣× # " " times...
$ # the number we're mapped over
æ # duplicate and reverse
ᐐp # prepend the tailless copy
f” # flatten and join by newlines
# implicit print
💎
Created with the help of Luminespire.
<script type="vyxal3">
①ʀƛkd↺$␣×j}æᐐpf”
¶p
</script>
<script>
args=[]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>
AWK, 67 bytes
{for(j=-9;j++<8;print)for(i=0;i++<10;)printf("%i%*s",i^2/i%10,j,X)}
Nim, 69 bytes
import strutils
for n in-8..8:echo "1234567890".join " ".repeat abs n
Tcl, 99 98 bytes
-1 thanks to sergiol
time {incr i;time {puts -nonewline [incr j][string repe \ [expr abs(9-$i)]]} 9;puts 0;unset j} 17
K (ngn/k), 27 24 bytes
-3 bytes from @ovs
`0:{(x#"")/$<~!10}'8-!17
8-!17generate8 7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8{...}'call code in{...}on each number in above list$<~!10generate"1234567890"(technically, rather than a single string of 10 digits, 10 strings each containing one digit is returned instead. but this is usable)(x#"")generate a number of spaces equal to the number input(...)/...join the right-side arg (the list of digit strings) by the left-side arg (the characters to join with)
`0:print to stdout
Regenerate, 66 bytes
(((${($3+1)%10}!1)( {#5*#1/10}! {#1/10-2}!({#1} )! {8})){10}
){17}
Explanation
The output consists of 17 lines, each of which consist of 10 digits, each digit followed by a run of spaces.
- The digits start at 1 and increase by 1 each time, wrapping around to 0 after reaching 9. We can generate these as "previous digit plus 1, mod 10."
- The spaces are a bit trickier. Within each line, the number of spaces is the same; from one line to another, it starts at 8, goes down to 0, and then goes back up to 8.
(((...)(...)){10}\n){17}
{17} 17 times,
( ) match group 1, a line of output, consisting of:
{10} 10 times,
( ) match group 2, consisting of:
(...) Group 3, a digit (see below)
(...) Group 4, a run of spaces (see below)
\n Then match a newline
Group 3:
${($3+1)%10}!1
${ } Match the result of this calculation:
$3 Previous value of group 3
+1 Plus 1
( )%10 Mod 10
! Or, if that fails because there is no previous value of group 3:
1 Match a literal 1
Group 4 (using underscores instead of spaces for clarity):
_{#5*#1/10}!_{#1/10-2}!({#1}_)!_{8}
_{ } Match this many spaces:
#5 Length of group 5
*#1 Times length of group 1
/10 Divided by 10
! If group 5 hasn't matched yet, fail and try:
_{ } Match this many spaces:
#1 Length of group 1
/10 Divided by 10
-2 Minus 2
! If group 1 hasn't matched yet, or if the result of
the calculation is a negative number, fail and try:
( ) Match group 5:
{#1} Fail if group 1 hasn't matched yet
_ Match a single space
! If that fails:
_{8} Match 8 spaces
The order of the alternatives doesn't make it very clear what's going on:
- The first time through, no groups have previous matches to reference, so the only alternative that matches is the last one,
{8}. This starts the first line with eight spaces. - After the first line, group 5 still hasn't matched yet but group 1 has, so we use the second alternative,
{#1/10-2}. The length of the previous line is \$10\cdot(s+1)+1\$, where \$s\$ is the number of spaces between the digits on the previous line. We want to calculate \$s-1\$ for the current line, so we divide by 10 and subtract 2. - On the ninth line, \$s\$ is 0, so for the tenth line,
#1/10-2is -1, which is illegal as a repetition count. So we fall through to the third alternative,({#1} ). This matches a single space and stores it in group 5. (The{#1}is there to make sure it doesn't match on line 1.) - Finally, after group 5 matches, we can match the first alternative,
{#5*#1/10}. Since group 5's contents are a single space, its length is always 1. So the calculation here simply divides the length of the previous line by 10, giving \$s+1\$.
Due to a bug in the logic in my first attempt (accidentally decreasing the number of spaces after every digit instead of every line), I managed to get this:
1 2 3 4 5 6 7 8 90
1 2 3 4 5 6 7 89 0
1 2 3 4 5 6 78 9 0
1 2 3 4 5 67 8 9 0
1 2 3 4 56 7 8 9 0
1 2 3 45 6 7 8 9 0
1 2 34 5 6 7 8 9 0
1 23 4 5 6 7 8 9 0
12 3 4 5 6 7 8 9 0
It looked cool, and including bugged output seemed appropriate to the challenge. ;^)
Scala, 77 76 bytes
(for(i<- -8 to 8)yield"1234567890".mkString(" "*math.abs(i)))foreach println
Thanks Kevin Cruijssen for 1 byte saved!
Zsh, 48 bytes
for 1 ({9..1} {2..9})printf %-$1s {1..9} 0&&echo
Similar to Spaceship Maw!. -4, -8 bytes thanks to @pxeger.
Thunno 2 N, 11 bytes
9LrⱮıṣkDỤsj
Explanation
9LrⱮıṣkDỤsj # Implicit input
9L # Push [0..9)
r # Reverse it
Ɱ # And palindromise that
ı # Map over this list:
ṣ # Push that many spaces
kDỤ # Push "1234567890"
sj # Join it by the spaces
# Join on newlines
# Implicit output
Vyxal j, 11 bytes
8ʀṘ∞ƛ9ʀǓ$Ij
8ʀṘ∞ƛ9ʀǓ$Ij
8ʀ # Range [0, 8]
Ṙ # Reverse
∞ # Palindromise, append reverse without first element.
# Produces [8, 7, 6, ..., 1, 0, 1, 2, ..., 7, 8]
ƛ # For each:
9ʀ # Range [0, 9]
Ǔ # Rotate it left to make [1,2,3,4,5,6,7,8,9,0]
$ # Swap so the current element is at the top
I # Push that many spaces
j # Join the number list by these spaces
# j flag joins on newlines
Dash*, 69 bytes
seq -- -8 8|xargs -I: sh -c 'seq -s"`printf "%:s_"`" 10'|sed s/_1*//g
Hopefully this iteration is fairly self explanatory -- pretty much a straight swap of for to xargs.
Dash*, 87, 86, 73 bytes
for p in `seq -- -8 8`;do seq -s"`printf "%${p}s_"`" 10;done|sed s/_1*//g
Explanation (for method)
for p in `seq -- -8 8`
Produce -8 to 8, used to create separator in next seq.
NB BusyBox’s* seq barfs on the -8 without the -- but TIO’s Dash env does not.
;do seq -s"`printf "%${p}s_"`" 10
Print 1-10, separated with p × spaces, with an extra _ appended (because seq won't accept an empty separator).
;done|sed s/_1*//g
Remove the _ as well as the 1 from trailing 10.
EDIT: removed a silly space (thanks Kevin Cruijssen)
EDIT: saved many bytes because negative padding printf doesn't matter
EDIT: scraped off another few bytes by ditching the for in favour of xargs.
*Actually this is aimed at Busybox 1.31.1 ash, sed, seq and printf, but TIO didn't have that environment. NB available seq options are limited to -w and -s.
Java (JDK), 105 103 bytes
a->{for(int j,i=-9;i++<8;){var s="";for(j=0;j++<9;)s+=j+" ".repeat(i<0?-i:i);System.out.println(s+0);}}
Thanks to ceilingcat for -2
MathGolf, 11 bytes
8╤{± *♂r╫up
Explanation
8 push 8
╤ range(-n, n+1)
{ for each element in range:
± absolute value
space character
* multiply space character x number of times
♂r push 10, create range
╫ left-rotate list (0 goes to the end)
u join with separator (joins using x spaces)
p print with newline
Has a trailing newline in the end from printing. @ovs found a mistake in the original code that could be fixed by switching the first 9 to an 8.
jq -nr, 50 46 45 bytes
[range(9)+1,0|@sh]|join(range(17)-8|" "*fabs)
[range(9)+1,0|@sh] generates the array ["1", "2", ..., "9", "0"]. This list is then joined by each of the results from:
range(17)-8: -8, -7, ..., 7, 8
" "*fabs a string of absolute value spaces
Excel, 74 bytes
=LET(x,MOD(COLUMN(A:J),10),CONCAT(x&IF(x,REPT(" ",ABS(ROW(1:17)-9)),"
")))
The version without LET that would have been valid when the question was asked is only 2 bytes longer.
Without LET, 76 bytes
=CONCAT(RIGHT(COLUMN(A:J))&IF(COLUMN(A:J)>9,"
",REPT(" ",ABS(ROW(1:17)-9))))
Deadfish~, 2606 bytes
ioi{iii}cccccccc{ddd}o{iii}ccccccccd{ii}ci{dd}cccccccc{ii}c{dd}cccccccci{ii}cd{dd}ccccccccii{ii}cdd{dd}ccccccccd{{{i}}}odsddddcccccccc{{{i}}}oddsddddcccccccci{ddd}soiii{ii}cccccccc{{d}}o{i}ci{d}oi{iii}ccccccc{ddd}o{iii}cccccccd{ii}ci{dd}ccccccc{ii}c{dd}ccccccci{ii}cd{dd}cccccccii{ii}cdd{dd}cccccccd{{{i}}}odsddddccccccc{{{i}}}oddsddddccccccci{ddd}soiii{ii}ccccccc{{d}}o{i}ci{d}oi{iii}cccccc{ddd}o{iii}ccccccd{ii}ci{dd}cccccc{ii}c{dd}cccccci{ii}cd{dd}ccccccii{ii}cdd{dd}ccccccd{{{i}}}odsddddcccccc{{{i}}}oddsddddcccccci{ddd}soiii{ii}cccccc{{d}}o{i}ci{d}oi{iii}ccccc{ddd}o{iii}cccccd{ii}ci{dd}ccccc{ii}c{dd}ccccci{ii}cd{dd}cccccii{ii}cdd{dd}cccccd{{{i}}}odsddddccccc{{{i}}}oddsddddccccci{ddd}soiii{ii}ccccc{{d}}o{i}ci{d}oi{iii}cccc{ddd}o{iii}ccccd{ii}ci{dd}cccc{ii}c{dd}cccci{ii}cd{dd}ccccii{ii}cdd{dd}ccccd{{{i}}}odsddddcccc{{{i}}}oddsddddcccci{ddd}soiii{ii}cccc{{d}}o{i}ci{d}oi{iii}ccc{ddd}o{iii}cccd{ii}ci{dd}ccc{ii}c{dd}ccci{ii}cd{dd}cccii{ii}cdd{dd}cccd{{{i}}}odsddddccc{{{i}}}oddsddddccci{ddd}soiii{ii}ccc{{d}}o{i}ci{d}oi{iii}cc{ddd}o{iii}ccd{ii}ci{dd}cc{ii}c{dd}cci{ii}cd{dd}ccii{ii}cdd{dd}ccd{{{i}}}odsddddcc{{{i}}}oddsddddcci{ddd}soiii{ii}cc{{d}}o{i}ci{d}oi{iii}c{ddd}o{iii}cd{ii}ci{dd}c{ii}c{dd}ci{ii}cd{dd}cii{ii}cdd{dd}cd{{{i}}}odsddddc{{{i}}}oddsddddci{ddd}soiii{ii}c{{d}}o{i}ciio{d}ioioioioioioioi{d}o{i}ci{d}oi{iii}c{ddd}o{iii}cd{ii}ci{dd}c{ii}c{dd}ci{ii}cd{dd}cii{ii}cdd{dd}cd{{{i}}}odsddddc{{{i}}}oddsddddci{ddd}soiii{ii}c{{d}}o{i}ci{d}oi{iii}cc{ddd}o{iii}ccd{ii}ci{dd}cc{ii}c{dd}cci{ii}cd{dd}ccii{ii}cdd{dd}ccd{{{i}}}odsddddcc{{{i}}}oddsddddcci{ddd}soiii{ii}cc{{d}}o{i}ci{d}oi{iii}ccc{ddd}o{iii}cccd{ii}ci{dd}ccc{ii}c{dd}ccci{ii}cd{dd}cccii{ii}cdd{dd}cccd{{{i}}}odsddddccc{{{i}}}oddsddddccci{ddd}soiii{ii}ccc{{d}}o{i}ci{d}oi{iii}cccc{ddd}o{iii}ccccd{ii}ci{dd}cccc{ii}c{dd}cccci{ii}cd{dd}ccccii{ii}cdd{dd}ccccd{{{i}}}odsddddcccc{{{i}}}oddsddddcccci{ddd}soiii{ii}cccc{{d}}o{i}ci{d}oi{iii}ccccc{ddd}o{iii}cccccd{ii}ci{dd}ccccc{ii}c{dd}ccccci{ii}cd{dd}cccccii{ii}cdd{dd}cccccd{{{i}}}odsddddccccc{{{i}}}oddsddddccccci{ddd}soiii{ii}ccccc{{d}}o{i}ci{d}oi{iii}cccccc{ddd}o{iii}ccccccd{ii}ci{dd}cccccc{ii}c{dd}cccccci{ii}cd{dd}ccccccii{ii}cdd{dd}ccccccd{{{i}}}odsddddcccccc{{{i}}}oddsddddcccccci{ddd}soiii{ii}cccccc{{d}}o{i}ci{d}oi{iii}ccccccc{ddd}o{iii}cccccccd{ii}ci{dd}ccccccc{ii}c{dd}ccccccci{ii}cd{dd}cccccccii{ii}cdd{dd}cccccccd{{{i}}}odsddddccccccc{{{i}}}oddsddddccccccci{ddd}soiii{ii}ccccccc{{d}}o{i}ci{d}oi{iii}cccccccc{ddd}o{iii}ccccccccd{ii}ci{dd}cccccccc{ii}c{dd}cccccccci{ii}cd{dd}ccccccccii{ii}cdd{dd}ccccccccd{{{i}}}odsddddcccccccc{{{i}}}oddsddddcccccccci{ddd}soiii{ii}cccccccc{{d}}o
Deadfish~ has two output commands, o to print the accumulator as an integer and c to print a character. All whitespace is printed with c, and 84 of the 190 digits are printed with c, determined by an exhaustive search. If you're interested, here is the semi-golfed and fully unreadable generator: Try it online!
Vyxal j, 15 bytes
8N8ṡȧƛð$ẋ9ʀ1Ǔ$j
-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
BRASCA, 72 bytes
8[a09Ir,m[oA:a[Eo{]x]xloA{]x09Ir,m[o]lo8[9$-a09Ir,m[oA:a[Eo{]x]xloA}9$-]
Pip -l, 18 16 bytes
(\,t)%tJsXPZRV,9
Explanation
t is 10, s is " " (implicit)
,9 Range(9): [0 1 2 3 4 5 6 7 8]
RV Reverse: [8 7 6 5 4 3 2 1 0]
PZ Palindromize: [8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8]
sX For each element of the above list, a string of that many spaces
\,t Inclusive-range(10): [1 2 3 4 5 6 7 8 9 10]
( )%t Mod 10: [1 2 3 4 5 6 7 8 9 0]
J For each string of spaces, join the above list on that string
Output the list of results one per line (`-l` flag)
The PZ operator was added more than a year after this challenge was posted, so here's a 17-byte answer that would have worked at that time:
(\,t)%tJsXAB:-8,9
Deadfish~, 2959 bytes
{iiiii}dc{dd}iiicccccccc{ii}ddc{dd}iicccccccc{ii}dc{dd}icccccccc{ii}c{dd}cccccccc{ii}ic{dd}dcccccccc{ii}iic{dd}ddcccccccc{ii}iiic{dd}dddcccccccc{ii}iiiic{dd}ddddcccccccc{ii}iiiiic{dd}dddddcccccccc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiiccccccc{ii}ddc{dd}iiccccccc{ii}dc{dd}iccccccc{ii}c{dd}ccccccc{ii}ic{dd}dccccccc{ii}iic{dd}ddccccccc{ii}iiic{dd}dddccccccc{ii}iiiic{dd}ddddccccccc{ii}iiiiic{dd}dddddccccccc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiicccccc{ii}ddc{dd}iicccccc{ii}dc{dd}icccccc{ii}c{dd}cccccc{ii}ic{dd}dcccccc{ii}iic{dd}ddcccccc{ii}iiic{dd}dddcccccc{ii}iiiic{dd}ddddcccccc{ii}iiiiic{dd}dddddcccccc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiiccccc{ii}ddc{dd}iiccccc{ii}dc{dd}iccccc{ii}c{dd}ccccc{ii}ic{dd}dccccc{ii}iic{dd}ddccccc{ii}iiic{dd}dddccccc{ii}iiiic{dd}ddddccccc{ii}iiiiic{dd}dddddccccc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiicccc{ii}ddc{dd}iicccc{ii}dc{dd}icccc{ii}c{dd}cccc{ii}ic{dd}dcccc{ii}iic{dd}ddcccc{ii}iiic{dd}dddcccc{ii}iiiic{dd}ddddcccc{ii}iiiiic{dd}dddddcccc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiiccc{ii}ddc{dd}iiccc{ii}dc{dd}iccc{ii}c{dd}ccc{ii}ic{dd}dccc{ii}iic{dd}ddccc{ii}iiic{dd}dddccc{ii}iiiic{dd}ddddccc{ii}iiiiic{dd}dddddccc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiicc{ii}ddc{dd}iicc{ii}dc{dd}icc{ii}c{dd}cc{ii}ic{dd}dcc{ii}iic{dd}ddcc{ii}iiic{dd}dddcc{ii}iiiic{dd}ddddcc{ii}iiiiic{dd}dddddcc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiic{ii}ddc{dd}iic{ii}dc{dd}ic{ii}c{dd}c{ii}ic{dd}dc{ii}iic{dd}ddc{ii}iiic{dd}dddc{ii}iiiic{dd}ddddc{ii}iiiiic{dd}dddddc{i}iiiiiic{dddd}iic{iiii}dcicicicicicicicic{d}ic{dddd}iic{iiii}dc{dd}iiic{ii}ddc{dd}iic{ii}dc{dd}ic{ii}c{dd}c{ii}ic{dd}dc{ii}iic{dd}ddc{ii}iiic{dd}dddc{ii}iiiic{dd}ddddc{ii}iiiiic{dd}dddddc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiicc{ii}ddc{dd}iicc{ii}dc{dd}icc{ii}c{dd}cc{ii}ic{dd}dcc{ii}iic{dd}ddcc{ii}iiic{dd}dddcc{ii}iiiic{dd}ddddcc{ii}iiiiic{dd}dddddcc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiiccc{ii}ddc{dd}iiccc{ii}dc{dd}iccc{ii}c{dd}ccc{ii}ic{dd}dccc{ii}iic{dd}ddccc{ii}iiic{dd}dddccc{ii}iiiic{dd}ddddccc{ii}iiiiic{dd}dddddccc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiicccc{ii}ddc{dd}iicccc{ii}dc{dd}icccc{ii}c{dd}cccc{ii}ic{dd}dcccc{ii}iic{dd}ddcccc{ii}iiic{dd}dddcccc{ii}iiiic{dd}ddddcccc{ii}iiiiic{dd}dddddcccc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiiccccc{ii}ddc{dd}iiccccc{ii}dc{dd}iccccc{ii}c{dd}ccccc{ii}ic{dd}dccccc{ii}iic{dd}ddccccc{ii}iiic{dd}dddccccc{ii}iiiic{dd}ddddccccc{ii}iiiiic{dd}dddddccccc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiicccccc{ii}ddc{dd}iicccccc{ii}dc{dd}icccccc{ii}c{dd}cccccc{ii}ic{dd}dcccccc{ii}iic{dd}ddcccccc{ii}iiic{dd}dddcccccc{ii}iiiic{dd}ddddcccccc{ii}iiiiic{dd}dddddcccccc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiiccccccc{ii}ddc{dd}iiccccccc{ii}dc{dd}iccccccc{ii}c{dd}ccccccc{ii}ic{dd}dccccccc{ii}iic{dd}ddccccccc{ii}iiic{dd}dddccccccc{ii}iiiic{dd}ddddccccccc{ii}iiiiic{dd}dddddccccccc{i}iiiiiic{dddd}iic{iiii}dc{dd}iiicccccccc{ii}ddc{dd}iicccccccc{ii}dc{dd}icccccccc{ii}c{dd}cccccccc{ii}ic{dd}dcccccccc{ii}iic{dd}ddcccccccc{ii}iiic{dd}dddcccccccc{ii}iiiic{dd}ddddcccccccc{ii}iiiiic{dd}dddddcccccccc{i}iiiiiic{dddd}iic
Rockstar, 127 126 124 bytes
-1 byte thanks to Kevin
F takes X
cut 1234567890 into L
join L with " "*X
say L
X's9
while X
let X be-1
F taking X
while X-8
let X be+1
F taking X
Try it here (Code will need to be pasted in)
Pushy, 27 bytes
Not the most elegant solution, but it does the job.
N9X@wL:Ocv:32;ZT:hT%#^"v;T'
Explanation:
N \ Set printing delimiter to empty string
9X \ Push range(9) to stack: [0, 1, 2, 3, 4, 5, 6, 7, 8]
@ \ Reverse: [8, 7, 6, 5, 4, 3, 2, 1, 0]
w \ Mirror: [8, 7, 6... 1, 0, 1... 6, 7, 8]
L: \ Length (17) times do:
Oc \ Go to (cleared) auxiliary stack
v: \ Pop top of main stack, and that many times:
32; Push character 32 (space)
Z \ Push 0
T \ Ten times do:
:hT% \ counter = (counter + 1) mod 10
# \ Print the counter
^"v; \ Print the rest of the stack (spaces)
T' \ Print a newline
Japt -R, 19 18 16 14 13 bytes
Aõ%A
£qYçÃÔÅê
Explanation
A :10
õ :Range [1,10]
%A :Modulo each by 10
\n :Assign to variable U
£ :Map each element at 0-based index Y
q : Join U with
Yç : Space repeated Y times
à :End map
Ô :Reverse
Å :Slice off first element
ê :Mirror
:Implicitly join with newlines and output
///, 244 bytes
/*/\/\///X/0
1*j/\/X*x/ *S/x *s/SS*-/S *_/s *(/- *)/_ *A/)2)3)4)5)6)7)8)9)*Bj_2_3_4_5_6_7_8_9_*Cjs2s3s4s5s6s7s8s9s*Dj(2(3(4(5(6(7(8(9(*Ej-2-3-4-5-6-7-8-9-*FjS2S3S4S5S6S7S8S9S*Gjx2x3x4x5x6x7x8x9x*Hj 2 3 4 5 6 7 8 9 /1ABCDEFGHX23456789HGFEDCBXA0
Java 11 (JDK), 98 bytes
o->{for(int i=-9;++i<9;)System.out.println("".join(" ".repeat(i<0?-i:i),"1234567890".split("")));}
- -14 bytes by switching to JDK 11, which now has a native
String::repeat.
Previous answer (Java (OpenJDK 8)), 113 112 bytes
o->{for(int i=-9;++i<9;)System.out.printf("".join("%1$"+(i<0?-i:i>0?i:"")+"s","1234567890".split(""))+"%n","");}
Explanations
I'm basically constructing the following String 17 times (N is a variable, not an actual value):
"1%1$Ns2%1$Ns3%1$Ns4%1$Ns5%1$Ns6%1$Ns7%1$Ns8%1$Ns9%1$Ns0%n"
It's all the expected digits, joined by %1$Ns where N is the number of spaces between each digit.
%1$Ns basically means "take the first argument and pad it until length is at least N". Also, %1$0s is not supported so a special case %1$s is made for 0.
Finally, I format-print that string using a single argument: "", so the formatter reuses always the same empty string, padding it with spaces as needed.
Saves
- 1 byte thanks to Kevin Cruijssen
Sisi, 239 bytes
0set s8
1set d0-1
2set o""
3set i1
4set o o+i
5jumpif i7
6jump17
7set x s
8jump11
9set o o+" "
10set x x-1
11jumpif x9
12set c9>i
13jumpif c15
14set i0-1
15set i1+i
16jump4
17print o
18set s s+d
19jumpif s21
20set d1
21set q9>s
22jumpif q2
The basic strategy is to run a loop from 8 down to 0 and back up to 8, constructing each line accordingly and printing it. I'm not going to write a detailed explanation, but if you're trying to follow the algorithm, the following key to the variable names may be helpful:
s: number of spaces to print between digitsd: direction of change ins(-1 or 1)o: the current line of outputi: the current digitx: loop counter while printing spacesc: conditional that tests whetheriis less than 9 (if not, we set it to -1 so it gets incremented to 0 instead of 10)q: conditional that tests whethersis less than 9 (if so, we continue looping)
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(" ");}
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
Elixir, 126 bytes
Enum.each 8..-8,fn n->IO.puts Enum.map Enum.into(1..10,[],&(rem &1,10)),&(Integer.to_string(&1)<>String.duplicate" ",abs n)end
Enum.each 8..-8,
fn n->
IO.puts
Enum.map
Enum.into(1..10, [], &(rem &1,10)),
&(Integer.to_string(&1) <> String.duplicate" ",abs n)
end
For each number in the range 8 to -8, do this anonymous function with the number as n. The function (inner to outer) sets the range 1 to 10 into a list after applying the remainder mod 10 (so we have the list 1,2,3,4,5,6,7,8,9,0). Then maps that list of numbers into strings, and concatenates the absolute value of n spaces onto the end. After getting each string we print out the whole list of strings... and Elixir doesn't put any delimiter on that by default.
Output:
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
JavaScript, 71 bytes
f=(i=8,q=[..."1234567890"].join(" ".repeat(i)))=>i?q+`
`+f(i-1)+`
`+q:q
QBasic, 66 bytes
An undeclared subroutine that takes no input and outputs to STDOUT
FOR i=-8TO 8
FOR j=49TO 57
?CHR$(j)SPC(ABS(i));
NEXT
?"0
NEXT
R, 51 bytes
for(i in abs(-8:8))cat(1:9,0,"
",sep=strrep(" ",i))
Managed to find some more bytes thanks to JayCe's suggestion in the comments.
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
VBA, 58 bytes
An immediate window function that takes no input and outputs to the console.
For i=-8To 8:For j=1To 9:?j &""Spc(Abs(i));:Next:?"0":Next
Ungolfed and Commented
For i=-8To 8 '' Iterate `i` from `-8` to `8`
For j=1To 9 '' Iterate `j` from `1` to `9`
?j &""Spc(Abs(i)); '' Print `j` and `i` spaces
Next '' Loop `j`
?"0" '' Print `0`, with a newline
Next '' Loop `i`
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])."
";
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";
Canvas, 20 15 bytes
9{9∔ ×9R0∔∑;*]─
Explanation:
9{9∔ ×9R0∔∑;*]─ | (Full code)
| Print (implicit)
9∔ × | 9-i spaces
9R0∔∑;* | Inserted between the characters of the string "1234567890"
9{ | For each i in [1-9]
] | Separated by newlines
─ | Palindromized vertically with 1 line of overlap
brainfuck, 209 bytes
++++++++[->+>+>+>++++>++++++>+>>+<<<<<<<<]>++>+>+>>>>>+<<<<<<-[->>>>>>[-<<<+.>[-<<.>>>+<]>[-<+>]>>+<]>[-<+<<<->>>>]<<<-<.<<<<.>]>[->>>>>[-<<<+.>>>>>[->+<<<<<<<.>>>>>>]>[-<+>]<<+<]>[-<+<<<->>>>]>+<<<<<.<<<<.>>]
I noticed there wasn’t a brainfuck submission yet, so I gave it my best shot. Definitely not the most golfed solution possible, but I’m not upset with the result.
Lua, 106 85 bytes
-21 bytes thanks to user202729
n="1L2L3L4L5L6L7L8L9L0"for i=-8,8,1 do print((n:gsub("L",(" "):rep(math.abs(i)))))end
Output has a trailing newline
Ungolfed
n="1L2L3L4L5L6L7L8L9L0"
for i=-8,8,1 do
print((n:gsub("L",(" "):rep(math.abs(i)))))
end
SOGL V0.12, 12 bytes
9{SUē↕∑}¹№╬«
Try it Here! Explanation:
9{ } 9 times do
SU push "1234567890"
ē push e, predefined with the input, which defaults to 0, and then increase it
↕ get that many spaces
∑ join the string of digits with those spaces
¹ collect the results in an array
№ reverse the array vertically
ή palindromize vertically with 1 overlap
PowerShell, 30 bytes
8..0+1..8|%{1..9+0-join' '*$_}
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.
Sink, 102 100 bytes
var v=range 0,17
var p=list.push(range 0,10),0
for var s:v
say list.join p,str.pad"",num.abs s-8
end
Try it online! (sort of, it's just a repl so you'll need to type it in)
-2 bytes thanks to @Kevin Cruijssen
Cubically, 2622 bytes
U3D1R3L1F3B1U1D3+3111111@6-2111@66666666+21111@6-21111@66666666+211111@6-211111@66666666+0@6-0@66666666+01@6-01@66666666+011@6-011@66666666+0111@6-0111@66666666+4@6-4@66666666+41@6-41@66666666+211@6-511111@6+5111111@6-2111@6666666+21111@6-21111@6666666+211111@6-211111@6666666+0@6-0@6666666+01@6-01@6666666+011@6-011@6666666+0111@6-0111@6666666+4@6-4@6666666+41@6-41@6666666+211@6-511111@6+5111111@6-2111@666666+21111@6-21111@666666+211111@6-211111@666666+0@6-0@666666+01@6-01@666666+011@6-011@666666+0111@6-0111@666666+4@6-4@666666+41@6-41@666666+211@6-511111@6+5111111@6-2111@66666+21111@6-21111@66666+211111@6-211111@66666+0@6-0@66666+01@6-01@66666+011@6-011@66666+0111@6-0111@66666+4@6-4@66666+41@6-41@66666+211@6-511111@6+5111111@6-2111@6666+21111@6-21111@6666+211111@6-211111@6666+0@6-0@6666+01@6-01@6666+011@6-011@6666+0111@6-0111@6666+4@6-4@6666+41@6-41@6666+211@6-511111@6+5111111@6-2111@666+21111@6-21111@666+211111@6-211111@666+0@6-0@666+01@6-01@666+011@6-011@666+0111@6-0111@666+4@6-4@666+41@6-41@666+211@6-511111@6+5111111@6-2111@66+21111@6-21111@66+211111@6-211111@66+0@6-0@66+01@6-01@66+011@6-011@66+0111@6-0111@66+4@6-4@66+41@6-41@66+211@6-511111@6+5111111@6-2111@6+21111@6-21111@6+211111@6-211111@6+0@6-0@6+01@6-01@6+011@6-011@6+0111@6-0111@6+4@6-4@6+41@6-41@6+211@6-511111@6+5111111@6+1@6+1@6+1@6+1@6+1@6+1@6+1@6+1@6-111111111@6-511111@6+5111111@6-2111@6+21111@6-21111@6+211111@6-211111@6+0@6-0@6+01@6-01@6+011@6-011@6+0111@6-0111@6+4@6-4@6+41@6-41@6+211@6-511111@6+5111111@6-2111@66+21111@6-21111@66+211111@6-211111@66+0@6-0@66+01@6-01@66+011@6-011@66+0111@6-0111@66+4@6-4@66+41@6-41@66+211@6-511111@6+5111111@6-2111@666+21111@6-21111@666+211111@6-211111@666+0@6-0@666+01@6-01@666+011@6-011@666+0111@6-0111@666+4@6-4@666+41@6-41@666+211@6-511111@6+5111111@6-2111@6666+21111@6-21111@6666+211111@6-211111@6666+0@6-0@6666+01@6-01@6666+011@6-011@6666+0111@6-0111@6666+4@6-4@6666+41@6-41@6666+211@6-511111@6+5111111@6-2111@66666+21111@6-21111@66666+211111@6-211111@66666+0@6-0@66666+01@6-01@66666+011@6-011@66666+0111@6-0111@66666+4@6-4@66666+41@6-41@66666+211@6-511111@6+5111111@6-2111@666666+21111@6-21111@666666+211111@6-211111@666666+0@6-0@666666+01@6-01@666666+011@6-011@666666+0111@6-0111@666666+4@6-4@666666+41@6-41@666666+211@6-511111@6+5111111@6-2111@6666666+21111@6-21111@6666666+211111@6-211111@6666666+0@6-0@6666666+01@6-01@6666666+011@6-011@6666666+0111@6-0111@6666666+4@6-4@6666666+41@6-41@6666666+211@6-511111@6+5111111@6-2111@66666666+21111@6-21111@66666666+211111@6-211111@66666666+0@6-0@66666666+01@6-01@66666666+011@6-011@66666666+0111@6-0111@66666666+4@6-4@66666666+41@6-41@66666666+211@6
Pretty simple, turns the cube to get it into this:
242
202
242
000131555313
010121535343
000131555313
424
454
424
Now the LEFT face sums up to 1. So we use the other faces to get as close to the desired ASCII values as possible, then just increment/decrement by 1.
This also works:
Cubically, 2938 bytes
:4/1+5@6/1+3@66666666+2@6-2@66666666:5+1/1+5@6/1+3@66666666:5+2/1+5@6/1+3@66666666:5+3/1+5@6/1+3@66666666:5+1@6:5/1+3@66666666:1/1+51@6:5/1+3@66666666:2/1+51@6:5/1+3@66666666/1+51@6:5/1+3@66666666/1+5@6:1/1+1@6:4/1+5@6/1+3@6666666+2@6-2@6666666:5+1/1+5@6/1+3@6666666:5+2/1+5@6/1+3@6666666:5+3/1+5@6/1+3@6666666:5+1@6:5/1+3@6666666:1/1+51@6:5/1+3@6666666:2/1+51@6:5/1+3@6666666/1+51@6:5/1+3@6666666/1+5@6:1/1+1@6:4/1+5@6/1+3@666666+2@6-2@666666:5+1/1+5@6/1+3@666666:5+2/1+5@6/1+3@666666:5+3/1+5@6/1+3@666666:5+1@6:5/1+3@666666:1/1+51@6:5/1+3@666666:2/1+51@6:5/1+3@666666/1+51@6:5/1+3@666666/1+5@6:1/1+1@6:4/1+5@6/1+3@66666+2@6-2@66666:5+1/1+5@6/1+3@66666:5+2/1+5@6/1+3@66666:5+3/1+5@6/1+3@66666:5+1@6:5/1+3@66666:1/1+51@6:5/1+3@66666:2/1+51@6:5/1+3@66666/1+51@6:5/1+3@66666/1+5@6:1/1+1@6:4/1+5@6/1+3@6666+2@6-2@6666:5+1/1+5@6/1+3@6666:5+2/1+5@6/1+3@6666:5+3/1+5@6/1+3@6666:5+1@6:5/1+3@6666:1/1+51@6:5/1+3@6666:2/1+51@6:5/1+3@6666/1+51@6:5/1+3@6666/1+5@6:1/1+1@6:4/1+5@6/1+3@666+2@6-2@666:5+1/1+5@6/1+3@666:5+2/1+5@6/1+3@666:5+3/1+5@6/1+3@666:5+1@6:5/1+3@666:1/1+51@6:5/1+3@666:2/1+51@6:5/1+3@666/1+51@6:5/1+3@666/1+5@6:1/1+1@6:4/1+5@6/1+3@66+2@6-2@66:5+1/1+5@6/1+3@66:5+2/1+5@6/1+3@66:5+3/1+5@6/1+3@66:5+1@6:5/1+3@66:1/1+51@6:5/1+3@66:2/1+51@6:5/1+3@66/1+51@6:5/1+3@66/1+5@6:1/1+1@6:4/1+5@6/1+3@6+2@6-2@6:5+1/1+5@6/1+3@6:5+2/1+5@6/1+3@6:5+3/1+5@6/1+3@6:5+1@6:5/1+3@6:1/1+51@6:5/1+3@6:2/1+51@6:5/1+3@6/1+51@6:5/1+3@6/1+5@6:1/1+1@6:4/1+5@6/1+5@6:5+1/1+5@6:5+2/1+5@6:5+3/1+5@6:5+1@6:1/1+51@6:2/1+51@6:3/1+51@6-1@6:1/1+1@6:4/1+5@6/1+3@6+2@6-2@6:5+1/1+5@6/1+3@6:5+2/1+5@6/1+3@6:5+3/1+5@6/1+3@6:5+1@6:5/1+3@6:1/1+51@6:5/1+3@6:2/1+51@6:5/1+3@6/1+51@6:5/1+3@6/1+5@6:1/1+1@6:4/1+5@6/1+3@66+2@6-2@66:5+1/1+5@6/1+3@66:5+2/1+5@6/1+3@66:5+3/1+5@6/1+3@66:5+1@6:5/1+3@66:1/1+51@6:5/1+3@66:2/1+51@6:5/1+3@66/1+51@6:5/1+3@66/1+5@6:1/1+1@6:4/1+5@6/1+3@666+2@6-2@666:5+1/1+5@6/1+3@666:5+2/1+5@6/1+3@666:5+3/1+5@6/1+3@666:5+1@6:5/1+3@666:1/1+51@6:5/1+3@666:2/1+51@6:5/1+3@666/1+51@6:5/1+3@666/1+5@6:1/1+1@6:4/1+5@6/1+3@6666+2@6-2@6666:5+1/1+5@6/1+3@6666:5+2/1+5@6/1+3@6666:5+3/1+5@6/1+3@6666:5+1@6:5/1+3@6666:1/1+51@6:5/1+3@6666:2/1+51@6:5/1+3@6666/1+51@6:5/1+3@6666/1+5@6:1/1+1@6:4/1+5@6/1+3@66666+2@6-2@66666:5+1/1+5@6/1+3@66666:5+2/1+5@6/1+3@66666:5+3/1+5@6/1+3@66666:5+1@6:5/1+3@66666:1/1+51@6:5/1+3@66666:2/1+51@6:5/1+3@66666/1+51@6:5/1+3@66666/1+5@6:1/1+1@6:4/1+5@6/1+3@666666+2@6-2@666666:5+1/1+5@6/1+3@666666:5+2/1+5@6/1+3@666666:5+3/1+5@6/1+3@666666:5+1@6:5/1+3@666666:1/1+51@6:5/1+3@666666:2/1+51@6:5/1+3@666666/1+51@6:5/1+3@666666/1+5@6:1/1+1@6:4/1+5@6/1+3@6666666+2@6-2@6666666:5+1/1+5@6/1+3@6666666:5+2/1+5@6/1+3@6666666:5+3/1+5@6/1+3@6666666:5+1@6:5/1+3@6666666:1/1+51@6:5/1+3@6666666:2/1+51@6:5/1+3@6666666/1+51@6:5/1+3@6666666/1+5@6:1/1+1@6:4/1+5@6/1+3@66666666+2@6-2@66666666:5+1/1+5@6/1+3@66666666:5+2/1+5@6/1+3@66666666:5+3/1+5@6/1+3@66666666:5+1@6:5/1+3@66666666:1/1+51@6:5/1+3@66666666:2/1+51@6:5/1+3@66666666/1+51@6:5/1+3@66666666/1+5@6
Uses the existing cube and division to get the required ASCII values.
Found using these answers.
MATL, 21 bytes
-9Zv"l4Y29YS10:q@*Q(c
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!.
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<......
Do I get brownie points for having ._. two times in the dump?
Python 2, 59 57 56 55 bytes
i=8;exec"print(' '*abs(i)).join('1234567890');i-=1;"*17
@Leaky Nun helped golfing this a lot, @Praind Suggested a method to save 1 byte, which I formerly thought of, but forgot to edit, @CotyJohnathanSaxman suggested changing the loop.
Explanation
i=8- Assigns the value8to a variable calledi.exec"..."*17- Execute that block of code (...) 17 times.print(...)- Output the result.' '*abs(i)- Create a String with a space repeated|i|times..join('1234567890')- Interleave the string created above with1234567890, such that|i|spaces are inserted between the digits.i-=1- Decrementi, and by executing it 17 times, it reaches-8, which creates te repetitive pattern with the help ofabs().
/// (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
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.
Additional step (thx to CalculatorFeline):
/./ //-/ //_/ / → /_/..//-/. //./ /
Python 3, 58 57 54 bytes
i=8
while i+9:print(*'1234567890',sep=' '*abs(i));i-=1
(thanks to @flornquake for the last three bytes; I completely forgot using sep to save vs. .join)
R, 108 bytes
for(i in abs(-8:8))cat(paste0(el(strsplit("1234567890","")),paste(rep(" ",i),collapse=""),collapse=""),"\n")
Just pasting and collapsing the strings.
Edit: thanks for Challenger5 for pointing out a problem. Fixed it now.
Edit 2: saved a byte thanks to bouncyball.
APL (Dyalog), 22 bytes
↑∊¨(1+|¯9+⍳17)↑¨¨⊂1⌽⎕D
⎕D Digits from zero to nine
1⌽ rotate one step right (puts zero at end)
⊂ enclose (to treat as unit)
(…)↑¨¨ for each of these numbers, take that many characters from each of the letters:
⍳17 one through seventeen
¯9+ subtract nine
| find the absolute values
1+ add one
∊¨ enlist (flatten) each
↑ change one layer of depth into a level of rank (matrify)
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" : ""));
}
}
JavaScript(ES2017), 83 73 72 68 bytes
Thanks Shaggy for saving 10 bytes. Thanks Craig for saving 1 byte. Thanks arcs for saving 4 bytes.
for(i=-9,a="";i++<8;)a+=[...`1234567890
`].join("".padEnd(i<0?-i:i))
for(i=-9,a="";i++<8;)a+=[...`1234567890
`].join("".padEnd(i<0?-i:i))
console.log(a);
.as-console-wrapper { max-height: 100% !important; top: 0; }
.as-console-row:after { display: none !important; }
Clojure, 126 99 bytes
-27 by fixing a couple of dumb mistakes. The outer use of a wasn't necessary, so I was able to get rid of a altogether and just write apply str once. That also allowed me to use a function macro for the main function, which saved some bytes. I also inlined the call to Math/abs instead of rebinding n-spaces.
Basically a Clojure port of @Mr.Xcoder's Python idea. In retrospect, I should have used the abs/range method for the diamond challenge originally, but I then I may not have produced the bugged output!
Pretty simple. Joins the number string with a number of spaces that depends on the current row.
#(doseq[n(range -8 9)](println(clojure.string/join(apply str(repeat (Math/abs n)\ ))"1234567890")))
(defn bugged []
(doseq [n-spaces (range -8 9)]
(println
(clojure.string/join
; "String multiplication"
(apply str
(repeat (Math/abs n-spaces) \space))
"1234567890"))))
Common Lisp, 85 bytes
(dotimes(i 17)(format t(format()"~~{~~,,~aa~~}
"(abs(- i 8)))'(1 2 3 4 5 6 7 8 9 0)))
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
[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);
}
}
PHP, 71 bytes
while($y<17)echo chunk_split(1234567890,1,str_pad("",abs($y++-8))),"
";
Run with -nr or test 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
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)}
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.
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.
C64 ASM, 358 bytes (102 bytes compiled with basicstub)
This is the closest I could get due to obvious limitations:
jsr $E544
lda #9
sta $FD
nl1: jsr dl
jsr il
dec $FD
bne nl1
inc $FD
nl2: ldy $FD
cpy #9
bne nt1
bl: jmp bl
nt1: iny
sty $FD
jsr dl
jsr il
jmp nl2
dl: clc
ldx #$31
ldy #0
lp: txa
sm: sta $0400, y
inx
cpx #$31
bne c1
rts
c1: cpx #$3A
bne nt2
ldx #$30
clc
nt2: tya
adc $FD
cmp #40
bcc c2
rts
c2: tay
jmp lp
il: lda sm+1
adc #39
bcc nc
inc sm+2
nc: sta sm+1
rts
(Could probably be optimized quite a bit)
Python, 84 bytes
for x in range(-8,9):
z=""
for y in range(1,11):z+=str(y%10)+" "*abs(x)
print(z)
T-SQL 145 152 bytes
DECLARE @ VARCHAR(MAX)=''SELECT TOP 17@+=REPLACE('1x2x3x4x5x6x7x8x9x0','x',SPACE(ABS(number-8)))+'
'FROM master..spt_values WHERE type='P'PRINT @
Updated to use:
master..spt_valuesto generate numbers (WHERE type = 'P', these are always consecutive, starting at 0)- @ZLK's
TOP 17idea - PRINT (to obey the rules - no stringlists)
- @JanDrozen's great idea of including the carriage return in the string (I counted that as just one byte - Windows CRLF what?)
- Idea of @Bridge to use just @ for variable name - all these tricks!!
Results:
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
(Thanks @JanDrozen for the REPLACE idea)
TSQL, 220 148 bytes
Improvement posted by ZLK:
DECLARE @ VARCHAR(MAX)=''SELECT TOP 17@+=REPLACE('1@2@3@4@5@6@7@8@9@0','@',SPACE(ABS(9-RANK()OVER(ORDER BY object_id))))+'
'FROM sys.objects PRINT @
Output:
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'
Thanks to Dada
C (gcc), 76 bytes
f(x,y){for(y=-9;++y<9;puts(""))for(x=10;x++;printf("%-*d",abs(y)+1,x%=10));}
It outputs some trailing spaces, which is supposed to be OK.
It prints the numbers using left-justified fields of dynamic length - that's what the format string %-*d is for.
The inner loop has some funny initialization (starts from 10; any multiple of 10 would be fine) to "simplify" its termination condition.
///, 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
#
Try it online! Or here, interactively!
Considerably long, but /// has no real way of modifying data elegantly.
Stacked, 33 bytes
9:>' '*[9~>\#`]"!:8~>#rev\,$out"!
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
Husk, 21 bytes
mΣṪ`:§+↔tḣR8' ṁs`:0ḣ9
This is a full program that prints to STDOUT. Try it online! There are lots of trailing spaces.
Explanation
Husk is still missing lots of essential stuff like a two-argument range function, so parts of this solution are a little hacky.
mΣṪ`:§+↔tḣR8' ṁs`:0ḣ9
ṁs`:0ḣ9 This part evaluates to the string "1234567890".
ḣ9 Range from 1 to 9.
`:0 Append 0.
ṁs Convert each number to string and concatenate.
§+↔tḣR8' This part evaluates to a list like [" "," ",""," "," "]
but with 17 elements instead of 5.
R8' A string of 8 spaces.
ḣ Take prefixes.
§+ Concatenate
↔ the reversal and
t tail of the prefix list, palindromizing it.
Ṫ Take outer product of the two lists
`: with respect to flipped prepeding.
This prepends each digit to each string of spaces.
mΣ Map concatenation over the results, computing the rows.
Implicitly join with newlines and print.
Vim, 35 bytes:
i1234567890<esc>qqYP:s/\d/& /g
YGp{q7@q
Explanation:
i1234567890<esc> " insert '1234567890'
qq " Record the following into register 'q'
Y " Yank a line
P " Paste it above us
:s/\d/& /g " Put a space after each number
Y " Yank this line
G " Move the end of the buffer
p " Paste the line
{ " Move the beginning of the buffer
q " Stop recording
7@q " Call macro 'q' 7 times
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
Haskell, 58 55 bytes
unlines["1234567890">>=(:(' '<$[1..abs n]))|n<-[-8..8]]
This is basically @nimi 's solution :)
Vim, 53 bytes
i1234567890^[^qq8a ^[lq8@qqeYpPqqqlxbequ^qw9@q@eq7@wdj
Where ^[ is the ESC Key.
i1234567890^[^ puts 1-9+0 in the buffer and returns the cursor to the beginning
qq8a ^[lq8@q puts 8 spaces between each of the numbers
qeYpPq records @e to duplicate the line twice and stay on the middle one
qqlxbequ^ records @q to delete one space between numbers and undoes it
qw9@q@eq records @w to do @q 9 times, then @e
7@wdj does @w 7 more times, then deletes two lines
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
Python 2, 72 bytes
for i in range(-8,9):print(('%-'+'%ds'%-~abs(i))*10)%tuple('1234567890')
05AB1E, 14 13 bytes
17F9ÝÀN8αð×ý,
Explanation
17F # for N in [0 ... 16] do
9Ý # push [0 ... 9]
À # rotate left
N8α # compute the absolute difference between N and 8
ð× # push that many spaces
ý # merge the list of digits with the space string as separator
, # print
SOGL V0.12, 14 bytes
ā9{SUčf@*∑Κ}╬Æ
Explanation:
ā push an empty array
9{ } 9 times do
SU push "1234567890"
č chop into characters
f@* get current iteration (0-based) amount of spaces
∑ join with that
Κ prepend this to the array
Β palindromize vertically with 1 overlap
Batch, 163 bytes
@set s=1 2 3 4 5 6 7 8 9 0
@set t=
@for %%l in (9 7)do @for /l %%i in (1,1,%%l)do @call:%%l
:7
@set t= %t%
:9
@set t=%t:~1%
@call echo %%s: =%t%%%
Note: First line ends in 9 spaces. Explanation: Uses creative line numbering! The first loop needs to run 9 times and delete a space each time, while the second loop needs to run 8 times and add a space each time. The former is achieved by running it 7 times and falling through for the 8th time, while the latter is achieved by adding two spaces and falling through to delete one of them again.
Charcoal, 18 bytes
F⁹⪫⁺…I¹:⟦0¶⟧× ι‖B↑
Try it online! Link is to verbose version of code. Explanation:
F⁹ Repeat 9 times (i = loop variable)
⪫ Join
⁺ Concatentate
…I¹: All the characters from str(1) below ":" (i.e. to "9") as a list
⟦0¶⟧ A list whose element is the string "0\n"
× ι With i spaces
‖B↑ Reflect everything upwards but without duplicating the top line
Note: Cast(1) takes the same number of bytes because "1" would need a separator before ":" (which as it happens the deverbosifier fails to insert).
C, 97 bytes
i=-9;main(j){for(;++i<9;putchar(10))for(j=0;++j<11;printf(" "+8-abs(i)))putchar(48+j%10);}
Your compiler will probably complain a lot about this code; mine threw 7 warnings of 4 different types. Might improve the code later.
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.
CJam, 21 bytes
A,(+aH*ee{:\8-zS**n}/
Explanation
A, e# Get [0 1 2 ... 9].
(+ e# Rotate the 0 to the end.
aH* e# Wrap in an array and repeat 17 times.
ee e# Enumerate. This pairs each copy of the array with its index in
e# the list.
{ e# For each [index array] pair...
:\ e# Unwrap the pair and swap its order.
8-z e# Get the absolute difference of the index from 8.
S* e# Get a string of that many spaces.
* e# Riffle the list of digits with the string of spaces.
n e# Print it with a trailing linefeed.
}/
Java 8, 235 234 206 163 bytes
interface A{static void main(String[]a){for(int i=-8;i<9;i++){String s="";for(int j=1,k;j<10;j++){s+=j;for(k=0;k<(i>0?i:-i);k++)s+=" ";}System.out.println(s+0);}}}
Update : -28 bytes thanks to Leaky Nun !
Update 2 : -43 bytes thanks to Leaky Nun again !
Ungolfed :
interface A {
static void main(String[] a) {
for (int i = -8; i < 9; i++) {
String s = "";
for (int j = 1, k; j < 10; j++) {
s += j;
for (k = 0; k < (i > 0 ? i : -i); k++)
s += " ";
}
System.out.println(s + 0);
}
}
}
EDIT : The code earlier was wrong ! Made a mistake while golfing the code, it should work as intended now !
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())
Charcoal, 21 20 19 18 bytes
F⁹«F…¹χ⁺κ… ι0⸿»‖B↑
Link to the verbose version. Basically I create the lower part of the drawing and then reflect the text up.
Mathematica, 92 bytes
Column@Join[Reverse@(s=Row/@Table[Riffle[Range@10~Mod~10,""<>Table[" ",i]],{i,0,8}]),Rest@s]
copy/paste code with ctrl-v
press shift+enter to run
Brachylog, 30 29 28 bytes
Ị↺{∧≜;Ṣj₍g;?↔zcc}ᶠ⁹↔;XcP↔Pẉᵐ
Saved one byte thanks to Leaky Nun.
Explanation
Ị↺ The string "1234567890"
{ }ᶠ⁹ Find the first 9 outputs of:
∧≜ Take an integer
;Ṣj₍ Juxtapose " " that number of times
g;?↔z Zip that string of spaces with "1234567890"
cc Concatenate twice into one string
↔ Reverse the resuling list
;XcP↔P Palindromize the list (concatenate X to it into the list P,
P reversed is still P)
ẉᵐ Map writeln
