g | x | w | all
Bytes Lang Time Link
075Swift 6250505T125932ZmacOSist
519TSQL SQL Server 2016230629T054407Zyoucantr
025Factor230628T163018Znoodle p
049C gcc170531T154954Zcleblanc
017Arturo230628T040825Zchunes
021Flip230628T032921Zuser1180
003Thunno 2230627T185817ZThe Thon
025Nibbles230313T180704Zxigoi
004Vyxal230312T115840ZThe Thon
032PowerShell Core201120T005312ZJulian
2012k170618T044952Zzgrep
035MUMPS201119T150417ZJoã
006Pyth200907T000105ZScott
066Nim201117T185518Zxigoi
00405AB1E201117T181251ZMakonede
006Husk201117T080310ZDominic
010APL Dyalog Extended200904T073819ZRazetime
005Pip200904T070618ZRazetime
005Japt200904T085423ZShaggy
079Common Lisp170617T215537ZRenzo
008Charcoal170531T174640ZNeil
008Jelly170531T144320ZJonathan
044PowerShell170601T212325Zcolsw
039Python 3.5170531T142810ZRod
052Python 3170601T160733Znocturam
057C170531T170937ZMD XF
004Pyke170601T124343ZBlue
068Java 8170601T111520ZKevin Cr
045Retina170531T171245ZNeil
013APL170531T233625Zuser7008
032QBIC170531T230343Zsteenber
021Julia170531T223408ZJulian W
072JavaScript ES6170531T161758ZRick Hit
017Ruby170531T151656ZMark Tho
038Aceto170531T165316ZL3viatha
6049Clojure170531T184730ZNikoNyrh
017Pyth170531T184405ZJim
020Octave170531T142447Zrahnema1
005MATL170531T180334ZDJMcMayh
nanBash170531T174559Zmarcosm
020V170531T173804ZDJMcMayh
033shortC170531T171906ZMD XF
003Ohm170531T164855ZFrodCube
00405AB1E170531T143653ZRiley
078Lua170531T162925ZBlab
074JavaScript ES6170531T143838ZShaggy
120brainfuck170531T160915ZDoorknob
071C#170531T154330ZTheLetha
053PHP170531T155119ZTitus
014Japt170531T145944ZTom
002GS2170531T153218ZDennis
035Mathematica170531T151402ZLegionMa
039Perl170531T150750ZGrimmy
032Haskell170531T144733Znimi
nan170531T145129ZBrad Gil
008CJam170531T144656ZBusiness
042PHP170531T142951ZJör
050R170531T142449ZGiuseppe
005Brachylog170531T142420ZFatalize

Swift 6, 75 bytes

let f={""+Set((32...126).map{.init(UnicodeScalar($0))}).subtracting($0+"")}

Try it on SwiftFiddle!

T-SQL (SQL Server 2016), 519 bytes

with X as(select 32a,char(32)b union all select a+1,char(a+1)from X where a<126),E AS(SELECT n FROM(VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0))E(n)),F AS(SELECT a.n FROM E a,E b),G AS(SELECT a.n FROM F a,F b),T AS(SELECT ROW_NUMBER()OVER(ORDER BY(SELECT NULL))n FROM G),I as(SELECT ASCII(SUBSTRING(t,n,1))a FROM T JOIN(select @i as t)S on T.n<=LEN(S.t)where n=0),R as(select b from X where a not in(select a from I))select STUFF((SELECT''+b FROM R FOR XML PATH(''),TYPE).value('(./text())[1]','VARCHAR(MAX)'),1,1,'')

... but this assumes the input string is in @i, therefore a runnable script will look like:

declare @i varchar(101) = 'Test';
    
with X as(select 32a,char(32)b union all select a+1,char(a+1)from X where a<126),E AS(SELECT n FROM(VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0))E(n)),F AS(SELECT a.n FROM E a,E b),G AS(SELECT a.n FROM F a,F b),T AS(SELECT ROW_NUMBER()OVER(ORDER BY(SELECT NULL))n FROM G),I as(SELECT ASCII(SUBSTRING(t,n,1))a FROM T JOIN(select @i as t)S on T.n<=LEN(S.t)where n=0),R as(select b from X where a not in(select a from I))select STUFF((SELECT''+b FROM R FOR XML PATH(''),TYPE).value('(./text())[1]','VARCHAR(MAX)'),1,1,'')

Try it online!

How it works

Use CTEs to split the input string into individual characters on separate rows in a result set; use a recursive CTE to generate a result set having individual characters on separate rows for all characters between ASCII values 32 and 126; select all rows from the latter where characters are not found in the former; use STUFF with FOR XML PATH to aggregate those characters (in lieu of the STRING_AGG function, which only arrived in SQL Server 2017).

Legible version

declare @input varchar(101) = 'Test';


with X as (
    select 32a, char(32)b
    union all
    select a+1, char(a+1) from X where a < 126
),
E(n) AS(
    SELECT n FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0))E(n)
),
E2(n) AS(
    SELECT a.n FROM E a, E b
),
E4(n) AS(
    SELECT a.n FROM E2 a, E2 b
),
cteTally(n) AS(
    SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) n
    FROM E4
),
INPUT_STRING as (
    SELECT ASCII( SUBSTRING(term, n, 1)) as [ASCII Code]
    FROM cteTally t
    JOIN (select @input as term) S on t.n <= LEN(S.term)
    where n = 0
),
DATA_RESULTS as (
     select b from X where a not in (select [ASCII Code] from INPUT_STRING) 
 )
 
 select STUFF( (SELECT '' + b FROM DATA_RESULTS FOR XML PATH (''),TYPE).value('(./text())[1]','VARCHAR(MAX)'), 1, 1, '' ) 
 ;

Why?

Because I can.

Can it be shorter?

Almost certainly!

Factor, 26 25 bytes

-1 byte by using from math.unicode instead of diff, as suggested by @chunes

[ 32 126 [a,b] swap ∖ ]

Try it online!

TIO uses an old build of Factor; on the latest version, [a,b] from math.ranges has moved to [a..b] from ranges.

Explanation

Code Explanation Stack
[ ... ] Quotation (anonymous function) "Hello!"
32 126 [a,b] Inclusive range from 32 to 126 "Hello!" T{ range f 32 95 1 }
swap Swap so range is below input T{ range f 32 95 1 } "Hello!"
Set difference " \"#$%&'()*+,-./012..."

This works because in Factor, a string is basically a list of codepoints, and all sequences are sets.

C (gcc), 75 72 70 68 50 49 bytes

Thanks to Peter -1 byte

i;f(s){for(i=31;++i<127;index(s,i)?:putchar(i));}

Try it online!

Arturo, 17 bytes

$=>[--@` `..`~`&]

Try it!

Takes and returns a list of characters.

$=>[         ; a function where input is assigned to &
    --       ; set difference
    @        ; reify range
    ` `..`~` ; the range of printable ascii characters
    &        ; input
]            ; end function

Flip, 21 bytes

'  |D '+1<D:|g DX: #

Attempt This Online!

ATO is not working right now, but I tested this locally. Contains a raw \x7F byte.

This would have been easier if I hadn't removed the J builtin, which generates an inclusive range.

Explanation

                             Push printable ASCII onto stack:

'                            Push space character
                             Loop body:
    D                            Duplicate the current char
      ' \x7f                     Push 127
          <                      Less than?
            :                    If so, mirror & do the following:
           D                         Duplicate TOS
         1
       +                             Add by 1
   |                                 Mirror the IP

                             Setwise difference w/ input:

              g              Read 1 char from the input
                D            Duplicate
                  :          Pop, is it nonzero? (i.e. not at EOF)
                             If so, mirror:
                 X               Remove all occurences of
                                 this char in the stack.
             |                   Mirror the IP back

                    #        When loop done, print entire stack as a string.
                             Terminate program.

Thunno 2, 3 bytes

kcḍ

Attempt This Online!

Explanation

kcḍ  # Implicit input
  ḍ  # Symmetric set difference with...
kc   # ...all printable ASCII characters
     # Implicit output

Nibbles, 2.5 bytes

--_"\n"

Attempt This Online!

Unfortunately, the printable characters built-in in Nibbles also includes the newline, so we have to explicitly exclude it.

Explanation

--_"\n"
-       List subtract
 -       list subtract
  _       printable characters
   "\n"   newline
         input

Vyxal, 4 bytes

kQ?F

Try it Online!

Explanation

kQ   # Printable ASCII
  ?F # Without the input

PowerShell Core, 39 32 bytes

$a=$args
' '..'~'|?{$_-cnotin$a}

Added splatting and case sensitivity

Try it online!

Inspired by colsw's answer

k, 20 12 bytes

-8 bytes thanks to coltim.

^[`c$32+!94]

Try it online!

Explanation:

     32+!94  /list of int values of all printable characters
  `c$        /turn into characters
^[         ] /partial function application of "except"

What except ^ does is remove all instances of each of element in the right/second argument from the left/first argument.

MUMPS, 35 bytes

r r,! f i=32:1:126 w:r'[$c(i) $c(i)

Explanation

Try the code here

Pyth, 7 6 bytes

.-srd\
-srd\

.- - Subtract the second string from the first:

  1. srd\ Create a range from space char to the delete char
  2. implicitly read input

Try it online!

Nim, 66 bytes

let s=stdin.readAll
for c in' '..'~':
 if c notin s:stdout.write c

Try it online!

05AB1E, 4 bytes

žQsм

Try it online!

žQsм  # full program
   м  # remove...
  s   # implicit input...
   м  # from...
žQ    # all ASCII characters
      # implicit output

Husk, 6 bytes

-⁰…" ~

Try it online!

APL (Dyalog Extended), 14 10 bytes

⍞~⍨' '…'~'

Try it online!

-4 bytes from Adám!(inclusive range)

Explanation

   ' '…'~'     range of chars in visible ASCII range
  ⍨            flip the arguments of the function on the left
⍞~             Get all characters not in input 

Pip, 5 bytes

PADCa

Removes all chacracters in the input from a predefined variable.

Try it online!

Pip, 9 bytes

PARM(X^a)

Converts the characters of the input to regex, and removes the characters from the printable ASCII builtin.

Try it online!

Japt, 5 bytes

;EkU1

Try it - includes all test cases

Note that quotation marks in input strings cannot be escaped in Japt and %s must be escaped with %%.

Common Lisp, 79 bytes

(defun f(s)(dotimes(x 95)(let((y(code-char(+ 32 x))))(or(find y s)(princ y)))))

Very straightforward code.

Charcoal, 18 15 10 8 bytes

Fγ¿¬№θιι

Try it online! Link is to verbose version of code. Edit: Saved 3 bytes by ranging over characters instead of integers. Saved a further 5 bytes when I discovered the undocumented γ variable which holds the printable ASCII characters. Saved a further 2 bytes when @ASCII-only fixed predefined inputs in verbose mode (the answer is still valid as it stands, it's only the try it online link that wouldn't have worked at the time).

Jelly, 8 bytes

Really, 8 bytes? Please, tell me I missed something!

32r126Ọḟ

Try it online!

How?

32r126Ọḟ - Main link: list of characters s
32r126   - inclusive range from 32 to 126 = [32,33,...,125,126]
      Ọ  - cast ordinals to characters = list of printable characters
       ḟ - filter discard if in s

Alternatively

“ ~‘r/Ọḟ - Main link
“ ~‘     - code-page indexes = [32,126]
    r/   - reduce by inclusive range = [32,33,...,125,126]
      Ọ  - cast from ordinals to characters = list of printable characters
       ḟ - filter discard if in s

Since this challenge a new atom which yields all printable ASCII characters, ØṖ, has been introduced making the following work for 3 bytes:

ØṖḟ

PowerShell, 44 Bytes

[char[]](32..126|?{$_-notin[char[]]"$args"})

creates an array of the numbers 32 through 126 (printable char codes)

finds the char codes not present in the input $args and then converts them back to a char array.

apparently the 1..5 -gt 3 trick doesn't work for -in or -notin, which would save a few bytes.

Python 3.5, 39 bytes

lambda n:{*map(chr,range(32,127))}-{*n}

Try it online!
Turns input into a set, and remove it from the set containing all ascii characters

Python 3, 52 bytes

I feel like there ought to be a shorter way to grab all the unicode characters than this set comprehension, but I haven't found it yet.

lambda s:''.join({chr(i+34)for i in range(93)}-set(s))

C, 57 bytes

i=32;f(char*s){for(;i<127;i++)!strchr(s,i)?putchar(i):0;}

How it works:

I'm sure this can be golfed.

Pyke, 4 bytes

~KR-

Try it here!

Java 8, 68 bytes

s->{for(char c=31;++c<127;System.out.print(s.contains(c+"")?"":c));}

Try it here.

Retina, 48 45 bytes

^
95$*~¶
+T`p`_p`(.)(?=\1)
s`(.)(?=.*\1)|¶.*

Try it online! Includes test cases. Works by prepending a line of 95 ~s, translating them into the printable ASCII characters, then deleting duplicate characters and the original input. Edit: Saved 3 bytes by matching the characters to be translated individually.

APL, 13 bytes

⍞~⍨⎕UCS31+⍳95

Straightforward:

       31+⍳95  ⍝ A vector 32 .. 126
   ⎕UCS        ⍝ as characters
 ~⍨            ⍝ without
⍞              ⍝ those read from character input.

QBIC, 32 bytes

[32,126|X=chr$(a)~instr(;,X)|\?X

Time to implement chr$ and instr in QBIC...

[32,126|    Loop from 32 to 126
X=chr$(a)   Make X$ to be the character with Ascii value a (a is our loop counter)
~instr(;,X) If our input string (read from cmd line) contains cjar X$
|           THEN (empty, no-op)
\?X         ELSE, print char X$

Julia, 21 bytes

s->setdiff(' ':'~',s)

JavaScript (ES6), 73 72 bytes

f=(s,i=95)=>i?f(s,i-1)+(s.includes(c=String.fromCharCode(i+31))?'':c):''

This builds the string recursively, excluding characters found in the input.

Snippet:

f=(s,i=95)=>i?f(s,i-1)+(s.includes(c=String.fromCharCode(i+31))?'':c):''

console.log(f('Hello, World!'));
console.log(f('Hi'));
console.log(f(''));
console.log(f(' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'));

Ruby, 23 18 17 bytes

->s{[*' '..?~]-s}

Uses a lambda function as per @sethrin's comments.

Previous versions:

[*' '..?~]-s.chars

(' '..'~').to_a-s.chars

Aceto, 38 bytes

cC|d
dXpc
=`I&
LM-1I
d@7F&
€92-
r4*2

Explanation

We first read the input string and explode it (, put the characters on the stack). Next, we push the numbers 34 (94*2-) and 127 (27F1-). The second value is then removed from the stack and memorized (M):

 M-1
  7F
€92-
r4*2

We then first set a catch mark so we can jump back to this place, and then duplicate the number on the stack (the 34). We load the 126 from the quick memory and test for equality, in which case we exit:

 X
=`
L
d@

Otherwise, we duplicate the value again, convert it to a character of that number and check whether that character is already on the stack (dcC). If it is, we mirror to the right side:

cC|
d

Otherwise, we duplicate the value and convert it to a character again, print that character, increment the value and raise an exception, jumping back to the catch mark.

   d
  pc
  I&

If we mirrored, we just increment and raise an exception, too (I&).

Clojure, 60 or 49 bytes

#(apply str(sort(apply disj(set(map char(range 32 127)))%)))

These "apply"s are killing me :/ Oh, if returning a list is fine then this is a bit shorter.

#(sort(apply disj(set(map char(range 32 127)))%))

Pyth, 17 bytes

Vr32 127I!}CNzpCN

The naive approach.

Explanation:

Vr32 127I!}CNzpCN
Vr32 127             For N in [32, 127[
           CN        Get the ASCII character for the code N
        I!}  z       If it is in the input string...
              pCN    ...then print it

Test it online!

Octave, 22 20 bytes

Thanks to @Luis Mendo saved 2 bytes.

@(s)setxor(32:'~',s)

Try it online!

Other answer:

@(s)setdiff(' ':'~',s)

Try it online!

MATL, 5 bytes

6Y2X~

Try it online!

Thanks to Luis Mendo for golfing 8 bytes off!

Explanation:

   X~   % The symmetric set difference
6Y2     % Between all printable ASCII
        % And the input string (implicit)
        % Implicitly display

Symmetric set difference will give every element that is present in exactly one of the two input sets. (but not both) This will always give the right answer, since the input set will always be a subset of the second set (all printable ASCII).

Original version:

32:126tGom~)c

Explanation:

32:126          % Push the range 32-126
      t         % Duplicate it on the stack
       G        % Push the input
        o       % Convert it to character points
         m      % Is member (0 for each char that isn't in input, 1 for each char that is)
          ~     % Logical NOT
           )    % Take the truthy elements of this array from the previous array (All Printable ASCII)
            c   % Display as a string

Bash, 47 43 40 bytes

printf %x {32..126}|xxd -r -p|tr -d "$1"

Try it online!

Generates hexa range, inverts hex dump to char an removes characters present in first parameter.

V, 20 bytes

òiÎflax
òcH ¬ ~@"<

Try it online!

Hexdump:

00000000: f269 ce66 1b6c 6178 0af2 6348 20ac 207e  .i.f.lax..cH . ~
00000010: 1b40 223c                                .@"<

shortC, 33 bytes

i;AOi=31;++i<'~';strchr(*@,i)?:Pi

Conversions made in this program:

The resulting program looks like:

i;int main(int argc, char **argv){for(i=31;++i<'~';strchr(*argv,i)?:putchar(i));}

Try it online!

Ohm, 3 bytes

α@─

Try it online!

Note: you can also enter your input as a string (example), but it fails for the empty input case.

05AB1E, 5 4 bytes

-1 thanks to Emigna

žQsK

Try it online!

žQ   # Push all printable characters
  s  # Swap input to the top
   K # Push a with no b's (remove input characters from all printable character)

Lua, 78 bytes

s=io.read()for i=32,126 do c=string.char(i)io.write(s:find(c,1,1)and""or c)end

JavaScript (ES6), 74 bytes

I'm sure there's a shorter way to do this!

s=>[...Array(95)].map((_,y)=>s.includes(c=String.fromCharCode(y+32))?"":c)

Try it

let f=
s=>[...Array(95)].map((_,y)=>s.includes(c=String.fromCharCode(y+32))?"":c)
oninput=_=>o.innerText=f(i.value).join``
o.innerText=f(i.value="Hello, World!").join``
<input id=i><pre id=o>

brainfuck, 120 bytes

+[+[>+<+<]>]>-[[>>]+[<<]>>-],[<+++++[>------<-]>-[>[>>]+[<<]>-]>[>>]<[-]<[-<<]>,]++++++++[->++++<]>[>[-<.>]<[->>+<<]>>+]

Try it online!

Wrapped:

+[+[>+<+<]>]>-[[>>]+[<<]>>-],[<+++++[>--
----<-]>-[>[>>]+[<<]>-]>[>>]<[-]<[-<<]>,
]++++++++[->++++<]>[>[-<.>]<[->>+<<]>>+]

Explained:

+[+[>+<+<]>]>-         initialize what we will now consider cell 0 to 95
[[>>]+[<<]>>-]         initialize cells 2 4 etc 95*2 to 1; end on cell 0 at 0
,[                     main input loop (for each char of input)
  <+++++[>------<-]>-  subtract 31 from the input
  [>[>>]+[<<]>-]       lay a trail of (input minus 31) ones in the empty spaces
  >[>>]<[-]<[-<<]>     use the trail to clear the appropriate "print" flag
,]                     keep reading input until it ends
++++++++[->++++<]>     initialize the cell directly before flag 1 to 32
[                      we'll let the accumulator overflow; no harm done
  >[-<.>]              print the accumulator if the flag is still set
  <[->>+<<]>>+         shift over the accumulator and increment it
]

C#, 74 71 bytes

using System.Linq;s=>new int[95].Select((n,i)=>(char)(i+32)).Except(s);

Old version with creating a range for 74 bytes:

using System.Linq;s=>Enumerable.Range(32,95).Select(n=>(char)n).Except(s);

PHP, 53 bytes

for($k=31;$k++<126;)~strstr($argn,$k)?:print chr($k);
# or
for($k=31;$k++<126;)echo~strstr($argn,$k)?"":chr($k);

Run as pipe with -r.

Japt, 14 bytes

Ho#_dÃf@bX ¥J

Try it online!

Saved 4 bytes thanks to Shaggy and obarakon

GS2, 2 bytes

ç7

Try it online!

How it works

    (implicit) Push the sting of all characters in STDIN on the stack.
ç   Push the string of all printable ASCII characters.
 7  Perform symmetric set difference.
    (implicit) Print the result to STDOUT.

Mathematica, 35 bytes

20~CharacterRange~126~Complement~#&

Anonymous function. Takes a list of characters as input and returns a list of characters as output.

Perl, 39 bytes

s!.*!"pack(c95,32..126)=~y/$_//dr"!ee

Run with perl -pe.

Haskell, 32 bytes

f x=[y|y<-[' '..'~'],all(/=y)x] 

Try it online!

Boring library function for set difference:

Haskell, 31 bytes

import Data.List
([' '..'~']\\)

Perl 6, 29 bytes

{[~] keys (' '..'~')∖.comb}

Note that the result is random because Sets are unordered.

Test it

Expanded:

{
  [~]        # reduce using string concatenation
             # (shorter than 「join '',」)

  keys       # get the keys from the Set object resulting from the following

  (' '..'~') # Range of printable characters
  ∖          # Set minus (this is not \ )
  .comb      # split the input into individual characters
}

There is also an ASCII version of (-), but it would require a space before it so that it isn't parsed as a subroutine call.

CJam, 8 bytes

'␡,32>q^

Where is a literal delete character.

Try it online!

'␡,       e# The range of all characters up to ~.
   32>    e# Slice it to be the range of all characters from space to ~.
      q^  e# Symmetric set difference with the input.

PHP, 42 Bytes

Input as array

Output as string

<?=join(array_diff(range(" ","~"),$_GET));

Try it online!

PHP, 53 Bytes

Input as string

Output as string

<?=join(array_diff(range(" ","~"),str_split($argn)));

replace <?=join with print_r for an output as array

Try it online!

R, 50 bytes

function(s)intToUtf8(setdiff(32:126,utf8ToInt(s)))

returns an anonymous function. Converts the input string to integers, computes the set difference between the printable range and the input values, and then converts them back to a string and returns it.

Try it online!

Brachylog, 5 bytes

ẹ;Ṭ↔x

Try it online!

Explanation

ẹ          Split the input string into a list of chars
 ;Ṭ↔x      Exterminate the chars from the string Ṭ of printable ASCII chars