g | x | w | all
Bytes Lang Time Link
023Uiua241210T055553ZAdelie
048Zsh241212T093915Zroblogic
013Japt m180327T111349ZShaggy
012Jelly180327T175301ZErik the
027K4180328T214727Zmkst
060JavaScript Node.js180327T142721ZDanielIn
012APL Dyalog180327T115853ZUriel
124Google Sheets180327T221536ZEngineer
027J180327T180826ZGalen Iv
094C gcc180328T095543Zgastropn
042Ruby180327T122900ZKirill L
020CJam180328T055758ZMarcos
013MATL180327T123336ZLuis Men
047Haskell180327T225314Zxnor
085ShellUtils180327T203628ZCSM
094Red180327T173651ZGalen Iv
030Perl 5 n180327T170824ZTon Hosp
026Retina180327T162515ZNeil
008Stax180327T161148Zrecursiv
058JavaScript180327T154419ZShaggy
014Pyth180327T150956Zuser4854
085SNOBOL4 CSNOBOL4180327T143901ZGiuseppe
033Perl 5 pl180327T142229ZXcali
095Javascript180327T141757ZLuis fel
013SOGL V0.12180327T133634Zdzaima
075R180327T115424ZGiuseppe
051Haskell180327T105738Ztotallyh
064Python 3180327T115449ZJo King
049Haskell180327T125402ZLaikoni
159C gcc180327T124747ZJonathan
053Java 8180327T120024ZKevin Cr
01305AB1E180327T105856ZAdnan
035Perl 6180327T114833Znwellnho
033APL+WIN180327T114029ZGraham
01305AB1E180327T110051ZEmigna

Uiua, 24 23 bytesSBCS

⍚(↘1⊏×°⊏⊸∊:⊂" -"+@0⇡10)

Input and output are a box array of strings. Try it online!

Explanation

⍚(↘1⊏×°⊏⊸∈:⊂" -"+@0⇡10) # Main bind
⍚(                    ) # For each boxed string, unbox it and do the following, reboxing it after:
            ⊂" -"+@0⇡10  # Build the string " -0123456789", call it D
         ⊸∈:             # Check which chars in D appear in the input string,
                           # keeping D below the resulting array on the stack;
                           # chars in both are denoted with 1, and those that are not with 0
       °⊏                # Push an array of 0-based indices of the array in ascending order
      ×                  # Multiply both arrays
     ⊏                   # Select chars in D with the array; 0 becomes " ", 1 becomes "-", etc.
   ↘1                    # Drop the leading space

Zsh, 50 48 bytes

for i;{for j (- {0..9})printf ${j/[^$i]/ };echo}

Try it Online! 50bytes

For each argument i we loop j over [-0123456789] and if j has a match in i, we printf $j. Or, replace a non-matched character with a space.

Japt -m, 16 13 bytes

I/O as an array of strings.

Ao ¬i- ËoU ú1

Try it

Ao ¬i- ËoU ú1     :Implicit map of each U in input array
A                 :10
 o                :Range [0,A)
   ¬              :Join
    i-            :Prepend "-"
       Ë          :Map
        oU        :  Remove characters not contained in U
           ú1     :  Right pad with spaces to length 1

Jelly, 12 bytes

ØD”-;¹⁶e?€Ʋ€

Try it online!

-2 thanks to Jonathan Allan reading a rule I didn't.

Note that the I/O format used in the TIO link is not the actual one, which is input as a list of string representations and output as a list of lines.

K4, 30 27 bytes

Solution:

{?[a in$x;a:"-",.Q.n;" "]}'

Example:

q)k){?[a in$x;a:"-",.Q.n;" "]}'1 729 4728510 -3832 748129321 89842 -938744 0 11111
"  1        "
"   2    7 9"
" 012 45 78 "
"-  23    8 "
"  1234  789"
"   2 4   89"
"-   34  789"
" 0         "
"  1        "

Explanation:

Return "-0123..." or " " based on the input. Interpreted right-to-left. No competition for the APL answer :(

{?[a in$x;a:"-",.Q.n;" "]}' / the solution
{                        }' / lambda for each
 ?[      ;          ;   ]   / if[cond;true;false]
                .Q.n        / string "0123456789"
            "-",            / join with "-"
          a:                / save as a
       $x                   / convert input to string
   a in                     / return boolean list where each a in x
                     " "    / whitespace (return when false)

JavaScript (Node.js), 60 bytes

a=>a.map(X=>"-0123456789".replace(/./g,x=>X.match(x)?x:" "))

Try it online!

APL (Dyalog), 32 12 bytes

28 bytes saved thanks to @Adám and @ngn

⊃¨⎕∘.∩'¯',⎕d

Try it online!

Google Sheets, 124 bytes

=Transpose(ArrayFormula(If(IsError(Find(Mid("-0123456789",Row($1:$11),1),Split(A1,",")))," ",Mid("-0123456789",Row($1:$11),1

Input is a comma-separated list in cell A1. Output is in the range B1:L? where ? is however many entries were input. (You can put the formula wherever you want, I just chose B1 for convenience.) Note that Sheets will automatically add four closing parentheses to the end of the formula, saving us those four bytes.

Screenshot

Another test case and another test case

Explanation:

J, 32 27 bytes

-5 bytes thanks to FrownyFrog!

10|.":(10<."."0@[)}11$' '"0

Try it online!

Original solution:

J, 32 bytes

(('_0123456789'i.[)}11$' '"0)@":

Explanation:

@": convert to characters and

}11$' '"0 change the content of an array of 11 spaces to these characters

'_0123456789'i.[ at the places, indicated by the indices of the characters in this list

Try it online!

C (gcc), 95 94 bytes

c,d;f(l,n)char**l;{for(;n--;l++)for(c=0;c<12;)putchar(strchr(*l,d=c++?c+46:45)?d:d^58?32:10);}

Try it online!

Input in the form of a list of strings. Output to STDOUT.

Ruby, 42 bytes

Anonymous lambda processing the array of numbers:

->a{a.map{|n|"-0123456789".tr"^#{n}",?\s}}

Try it online!

Alternatively, a completely Perl-like full program is much shorter. I'd say -pl switches look quite funny in this context:

Ruby -pl, 29 bytes

$_="-0123456789".tr"^#$_"," "

Try it online!

Finally, the following is possible if it is acceptable for the output strings to be quoted:

Ruby -n, 27 bytes

p"-0123456789".tr ?^+$_,?\s

Try it online!

CJam, 20 bytes

qS%{'-10,+s_@-SerN}/

Try it online!

Accepts input as space separated list of integers. Pretty much the same approach as @adnans answer.

MATL, 13 bytes

"45KY2ht@gm*c

Input is a cell array of strings. Try it online! Or verify all test cases.

Explanation

         % Implicit input: cell array of strings, for example {'1','729',...,'11111'}
"        % For each cell
  45     %   Push 45 (ASCII code of '-')
  KY2    %   Push predefined literal '0123456789'
  h      %   Concatenate horizontally: gives '-0123456789'
  t      %   Duplicate
  @      %   Push current cell, for example {'729'}
  g      %   Convert cell to matrix. This effectively gives the cell's contents, '729'
  m      %   Ismember: gives an array of zeros and ones indicating membership of each
         %   char from '-0123456789' in '729'. The result in the example is
         %   [0 0 0 1 0 0 0 0 1 0 1]
  *      %   Multiply, element-wise. Chars are implicity converted to ASCII 
         %   Gives the array [0 0 0 50 0 0 0 0 55 0 57] 
  c      %   Convert ASCII codes to chars. 0 is displayed as space. Gives the string
         %   '   2    7 9'
         % Implicit end
         % Implicilly display each string on a different line

Haskell, 47 bytes

map(\s->do d<-"-0123456789";max" "[d|elem d s])

Try it online!

Uses max to insert a space where no element exist, since a space is smaller than any digit or minus sign.

If an ungodly number of trailing spaces is OK, two bytes can be saved:

45 bytes

map(\s->do d<-'-':['0'..];max" "[d|elem d s])

Try it online!

ShellUtils, 85 bytes

There must be a better way of escaping the {} rather than using a double echo and piping through bash

xargs -i echo echo \\-0123456789 \|tr \$\(echo .0123456789- \|tr -d -- {} \) \' \'|sh

This takes the strings, one per line, from stdlin The inner tr takes -0123456789 and removes what's not in the input line. The {} represents this.

The second tr takes that output, and converts -0123456789 by replacing the input characters with spaces.

Red, 94 bytes

func[b][foreach a b[s: copy"           "foreach c a[s/(index? find"-0123456789"c): c]print s]]

Takes input as a block of strings

Try it online!

Perl 5 -n, 30 bytes

Wouldn't work if - could appear anywhere else than in the first position

#!/usr/bin/perl -n
say"-0123456789"=~s/[^$_]/ /gr

Try it online!

Retina, 26 bytes

%"-0123456789"~`.+
[^$&]¶ 

Try it online! Note: Trailing space. Explanation: % executes its child stage ~ once for each line of input. ~ first executes its child stage, which wraps the line in [^ and ]<CR><SP>, producing a program that replaces characters not in the line with spaces. The "-0123456789" specifies that the input to that program is the given string ($ substitutions are allowed but I don't need them).

Stax, 8 bytes

║V≡u╝─é╢

Run and debug it

It takes one number per line on standard input. It works by finding the target index of each character and assigning it into that index of the result. If the index is out of bounds, the array is expanded with zeroes until it fits. During output, 0 becomes a space. The rest are character codes.

Unpacked, ungolfed, and commented, this is what it looks like.

m       for each line of input, execute the rest of the program and print the result
 zs     put an empty array under the line of input
 F      for each character code in the line of input, run the rest of the program
  Vd    "0123456789"
  I^    get the index of the character in this string and increment
  _&    assign this character to that index in the original string

Run this one

JavaScript, 59 58 bytes

Input & output as an array of strings.

a=>a.map(x=>`-0123456789`.replace(eval(`/[^${x}]/g`),` `))

Try it

o.innerText=(g=s=>(f=
a=>a.map(x=>`-0123456789`.replace(eval(`/[^${x}]/g`),` `))
)(s.split`,`).join`\n`)(i.value="1,729,4728510,-3832,748129321,89842,-938744,0,11111");oninput=_=>o.innerText=g(i.value)
input{width:100%;}
<input id=i><pre id=o></pre>


Original

Takes input as an array of strings and outputs an array of character arrays

a=>a.map(x=>[...`-0123456789`].map(y=>-~x.search(y)?y:` `))

o.innerText=(g=s=>(f=
a=>a.map(x=>[...`-0123456789`].map(y=>-~x.search(y)?y:` `))
)(s.split`,`).map(x=>x.join``).join`\n`)(i.value="1,729,4728510,-3832,748129321,89842,-938744,0,11111");oninput=_=>o.innerText=g(i.value)
input{width:100%;}
<input id=i><pre id=o></pre>

Pyth, 14 bytes

VQm*d}dNs+\-UT

Takes input as list of strings and outputs a list of strings for each line.
Try it here

Explanation

VQm*d}dNs+\-UT
VQ                For each string in the input...
  m     s+\-UT    ... and each character in "-0123456789"...
     }dN          ... check if the character is in the string...
   *d             ... and get that character or an empty string.

SNOBOL4 (CSNOBOL4), 85 bytes

I	X =INPUT	:F(END)
	S ='-0123456789'
R	S NOTANY(X ' ') =' '	:S(R)
	OUTPUT =S	:(I)
END

Try it online!

I	X =INPUT	:F(END)		;* read input, if none, goto end
	S ='-0123456789'		;* set the string
R	S NOTANY(X ' ') =' '	:S(R)	;* replace characters of S not in X + space with space
	OUTPUT =S	:(I)		;* print S, goto I
END

Perl 5 -pl, 33 bytes

$_=eval"'-0123456789'=~y/$_/ /cr"

Try it online!

Takes input as line separated.

Javascript 95 bytes

(a,t='-0123456789')=>a.map(a=>a+'').map(_=>[...t].map(b=>_.search(b)>=0?b:' ').join``).join`\n`

f=(a,t='-0123456789')=>a.map(a=>a+'').map(_=>[...t].map(b=>_.search(b)>=0?b:' ').join``).join`\n`

console.log(f([1,729,4728510,-3832,748129321,89842,-938744,0,11111]))

console.log(f([4,534,4,4,53,26,71,835044,-3559534,-1027849356,-9,-99,-3459,-3459,-94593,-10234567859]))

SOGL V0.12, 14 13 bytes

{ø,{²²⁴WI1ž}P

Try it Here!

Explanation:

{ø,{²²⁴WI1ž}P

{            repeat input times
 ø,            push an empty string and the next input above that
   {       }   for each character in the input
    ²²           push "0123456789"
      ⁴          copy the character on top
       W         and get it's index in that string (1-indexed, 0 for the non-existent "-")
        I        increment that (SOGL is 1-indexed, so this is required)
         1ž      at coordinates (index; 1) in the string pushed earlier, insert that original copy of the character
            P  print the current line

R, 96 75 bytes

for(i in scan())cat(paste(gsub(paste0("[^",i,"]")," ","-0123456789"),"\n"))

Try it online!

Thanks to Kevin Cruijssen for suggesting this regex approach!

Takes input from stdin as whitespace separated integers, and prints the ascii-art to stdout.

Haskell, 51 bytes

-1 byte thanks to Laikoni.

f l=[[last$' ':[n|n`elem`i]|n<-"-0123456789"]|i<-l]

Try it online!

This challenge is digitist. D:

Python 3, 77 64 bytes

-12 bytes thanks to @Rod

lambda x:[[[" ",z][z in str(y)]for z in"-0123456789"]for y in x]

Try it online!

My first proper attempt at golfing in Python. Advice welcome!

Returns a 2D array of characters.

Haskell, 49 bytes

map$(<$>"-0123456789").(%)
i%n|elem n i=n|1<3=' '

The first line defines an anonymous function which takes a list of strings and returns a list of strings. Try it online!

C (gcc), 159 bytes

f(A,l,j,k,b)long*A,k;{char*s,S[99];for(j=~0;++j<l;puts(""))for(sprintf(S,"%ld",k=A[j]),putchar(k<0?45:32),k=47;++k<58;putchar(b?32:k))for(b=s=S;*s;b*=*s++-k);}

Try it online!

Java 8, 53 bytes

a->a.map(i->"-0123456789".replaceAll("[^"+i+"]"," "))

My own challenge is easier than I thought it would be when I made it..

Input and output both as a java.util.stream.Stream<String>.

Explanation:

Try it online.

a->                              // Method with String-Stream as both input and return-type
  a.map(i->                      //  For every String in the input:
    "-0123456789"                //   Replace it with "-0123456789",
    .replaceAll("[^"+i+"]"," ")) //   with every character not in `i` replaced with a space

05AB1E, 13 bytes

Code:

v'-žh«DyмSð:,

Uses the 05AB1E encoding. Try it online!

Explanation:

v               # For each element in the input..
 '-žh«          #   Push -0123456789
      D         #   Duplicate this string
       yм       #   String subtraction with the current element
                    e.g. "-0123456789" "456" м  →  "-0123789"
         Sð:    #   Replace all remaining elements with spaces
                    e.g. "-0123456789" "-0123789" Sð:  →  "     456   "
            ,   #   Pop and print with a newline

Perl 6, 35 bytes

{.map:{map {m/$^a/||' '},'-',|^10}}

Try it online!

Output is a character matrix containing either regex matches or space characters.

APL+WIN, 33 bytes

Prompts for screen input as a string

n←11⍴' '⋄n['-0123456789'⍳s]←s←⎕⋄n

05AB1E, 17 13 bytes

Saved 4 bytes thanks to Adnan

vðTúyvyÐd+ǝ},

Try it online!

Explanation

v               # loop over elements y in input
 ðTú            # push a space prepended by 10 spaces
    yv          # for each element y in the outer y
      y         # push y
       Ðd+      # push y+isdigit(y)
          ǝ     # insert y at this position in the space-string
           }    # end inner loop
            ,   # print