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 code-golf, 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.
- If possible, please add a link with a test for your code.
- Also, please add an explanation if necessary.
-
\$\begingroup\$ Is outputting an array of strings - 1 string per line - allowed? \$\endgroup\$Shaggy– Shaggy2017年07月03日 09:37:05 +00:00Commented Jul 3, 2017 at 9:37
-
\$\begingroup\$ @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. \$\endgroup\$Kevin Cruijssen– Kevin Cruijssen2017年07月03日 11:06:21 +00:00Commented Jul 3, 2017 at 11:06
-
1\$\begingroup\$ No worries, Kevin; was just chancing my arm to see if I could save myself a couple of bytes. \$\endgroup\$Shaggy– Shaggy2017年07月03日 11:09:18 +00:00Commented Jul 3, 2017 at 11:09
-
3\$\begingroup\$ @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? ;) \$\endgroup\$Kevin Cruijssen– Kevin Cruijssen2017年07月03日 11:23:48 +00:00Commented Jul 3, 2017 at 11:23
-
14\$\begingroup\$ Ha, that's awesome. I was wondering why that answer suddenly got so much attention. Thanks! \$\endgroup\$Carcigenicate– Carcigenicate2017年07月03日 19:41:10 +00:00Commented Jul 3, 2017 at 19:41
97 Answers 97
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.
-
1\$\begingroup\$ Nice answer! Powershell suddenly feels more golfy :) \$\endgroup\$Mr. Xcoder– Mr. Xcoder2017年08月29日 19:56:28 +00:00Commented Aug 29, 2017 at 19:56
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
-
\$\begingroup\$ Sorry... \$\endgroup\$emanresu A– emanresu A2021年09月04日 11:00:40 +00:00Commented Sep 4, 2021 at 11:00
-
\$\begingroup\$ @emanresuA Yeah I've seen that before writing the answer. I will let you know when I posted an answer to a challenge you haven't \$\endgroup\$ovs– ovs2021年09月04日 11:43:13 +00:00Commented Sep 4, 2021 at 11:43
-
\$\begingroup\$
joinalready usestostringto take care of the string conversion, so you can drop@shentirely. \$\endgroup\$pmf– pmf2025年07月01日 21:23:41 +00:00Commented Jul 1 at 21:23
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.
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'
Thanks to Dada
-
\$\begingroup\$ That's nice!
-Eflag is free per our consensus. Also, you probably wanted-8..8instead 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). \$\endgroup\$Dada– Dada2017年07月03日 09:11:33 +00:00Commented Jul 3, 2017 at 9:11 -
\$\begingroup\$ You don't even need to declare
@l: just usesay 1..9,0:) \$\endgroup\$Dada– Dada2017年07月03日 09:17:19 +00:00Commented Jul 3, 2017 at 9:17
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.
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
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!.
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";
-
\$\begingroup\$ Welcome to the site, and be sure to check these tips for golfing in PHP! \$\endgroup\$2018年04月05日 10:16:10 +00:00Commented Apr 5, 2018 at 10:16
-
-
\$\begingroup\$
str_pad("",abs($i))is four bytes shorter thanstr_repeat(' ',abs($i)). \$\endgroup\$Titus– Titus2018年10月28日 09:56:04 +00:00Commented Oct 28, 2018 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
-
\$\begingroup\$
0..16=>^17\$\endgroup\$Jo King– Jo King2018年07月26日 01:08:06 +00:00Commented Jul 26, 2018 at 1:08 -
-
\$\begingroup\$ Thanks, there's always more to learn :) Interestingly, the code that runs on TIO perl6 does not run with rakudo, unless I change $++ to $_++ \$\endgroup\$whofferbert– whofferbert2018年07月26日 01:20:37 +00:00Commented Jul 26, 2018 at 1:20
-
-
1\$\begingroup\$ 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. \$\endgroup\$whofferbert– whofferbert2018年07月26日 01:37:08 +00:00Commented Jul 26, 2018 at 1:37
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
-
1\$\begingroup\$ Welcome to PPCG! Great first answer. \$\endgroup\$mbomb007– mbomb0072018年07月27日 02:58:20 +00:00Commented Jul 27, 2018 at 2:58
-
2\$\begingroup\$ Welcome to PPCG! This is indeed a great first answer, +1 from me. 7 bytes can be saved by removing all the brackets and putting everything inside the loop declarations:
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(" ");}128 bytes Enjoy your stay! \$\endgroup\$Kevin Cruijssen– Kevin Cruijssen2018年07月27日 07:01:23 +00:00Commented Jul 27, 2018 at 7:01 -
1\$\begingroup\$ 84 bytes by utilizing a single loop, print, and iteration variable, and switching to
f()instead of main. \$\endgroup\$user77406– user774062018年10月28日 18:53:42 +00:00Commented Oct 28, 2018 at 18:53 -
1\$\begingroup\$ 69 bytes building on @Rogem \$\endgroup\$ceilingcat– ceilingcat2018年12月23日 18:40:17 +00:00Commented Dec 23, 2018 at 18:40
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
-
\$\begingroup\$ 15 bytes because structures auto-complete \$\endgroup\$Aaroneous Miller– Aaroneous Miller2021年05月11日 12:22:13 +00:00Commented May 11, 2021 at 12:22
-
\$\begingroup\$ @AaronMiller oh right, that's why i was using the
jflag \$\endgroup\$2021年05月11日 12:45:17 +00:00Commented May 11, 2021 at 12:45 -
\$\begingroup\$ 13 bytes \$\endgroup\$Aaroneous Miller– Aaroneous Miller2021年09月08日 02:20:24 +00:00Commented Sep 8, 2021 at 2:20
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.
-
1\$\begingroup\$ Welcome to Code Golf, and nice first answer! Be sure to check out our Tips for golfing in Bash page for ways you can golf your program (they're likely to be applicable to Dash as well) \$\endgroup\$pxeger– pxeger2021年09月07日 08:46:25 +00:00Commented Sep 7, 2021 at 8:46
-
1\$\begingroup\$ Nice first answer, welcome to CGCC! I think you can remove the space between
10 ;? \$\endgroup\$Kevin Cruijssen– Kevin Cruijssen2021年09月07日 09:36:44 +00:00Commented Sep 7, 2021 at 9:36 -
\$\begingroup\$ Not sure how that sneaked in there, thanks @KevinCruijssen \$\endgroup\$bxm– bxm2021年09月07日 11:40:31 +00:00Commented Sep 7, 2021 at 11:40
Zsh, 48 bytes
for 1 ({9..1} {2..9})printf %-1ドルs {1..9} 0&&echo
Try it Online!
(削除) 49b (削除ここまで) (削除) 61b (削除ここまで) (削除) 57b (削除ここまで)
Similar to Spaceship Maw!. -4, -8 bytes thanks to @pxeger.
-
1\$\begingroup\$ 57: Try it online! \$\endgroup\$pxeger– pxeger2021年01月25日 19:26:28 +00:00Commented Jan 25, 2021 at 19:26
-
1\$\begingroup\$ 49: Try it online! \$\endgroup\$pxeger– pxeger2021年03月27日 15:27:36 +00:00Commented Mar 27, 2021 at 15:27
Swift 6, (削除) 106 (削除ここまで) 83 bytes
for i in -8...8{print(""+(1...10).flatMap{"\(0ドル%10)"+{String.init}()(" ",abs(i))})}
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
-
\$\begingroup\$ I feel there is a room for an improvement, though \$\endgroup\$Sergii Martynenko Jr– Sergii Martynenko Jr2017年07月04日 13:50:14 +00:00Commented Jul 4, 2017 at 13:50
-
1\$\begingroup\$ 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 hereq()}}; f(1,false? \$\endgroup\$Kevin Cruijssen– Kevin Cruijssen2017年07月04日 14:24:09 +00:00Commented Jul 4, 2017 at 14:24 -
\$\begingroup\$ 171 bytes \$\endgroup\$user3151675– user31516752018年04月05日 16:52:07 +00:00Commented Apr 5, 2018 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.
-
\$\begingroup\$ 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";\$\endgroup\$halfmang– halfmang2017年07月20日 17:48:06 +00:00Commented Jul 20, 2017 at 17:48 -
\$\begingroup\$ Oops! Looks like I made an incorrect assumption about the output. I thought it was 123456789 \$\endgroup\$halfmang– halfmang2017年07月20日 17:51:23 +00:00Commented Jul 20, 2017 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<......
Do I get brownie points for having ._. two times in the dump?
-
-
1\$\begingroup\$ How did I get out-golfed in Bubblegum? o0 What compression method did you use? \$\endgroup\$totallyhuman– totallyhuman2017年07月20日 18:07:26 +00:00Commented Jul 20, 2017 at 18:07
-
-
\$\begingroup\$ For some reason the byte count went up with more then 314 iterations. zopfli link \$\endgroup\$ovs– ovs2017年07月20日 18:10:31 +00:00Commented Jul 20, 2017 at 18:10
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.
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
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
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))))
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
Explore related questions
See similar questions with these tags.