# 八进制，十进制还是十六进制？

11

``````31
==> 1

47
==> ' / G

69
==> E i

7A
==> z

100
==> @ d

156
==> n

189
==> <empty>

potaTO
==> <empty>

5G
==> <empty>

19
==> <empty>
``````

6

## JavaScript（SpiderMonkey 30 +），74个字节

``````s=>[for(b of'o0x')if((c=+(0+b+s))>31&c<127)String.fromCharCode(c)].join` `
``````

Conor O'Brien

2
@CᴏɴᴏʀO'Bʀɪᴇɴ当您同时使用`map`和时`filter`，数组理解确实很有用。

@Neil任何理由使用`'0'+b+...``b`将始终是一个字符串？`0+b+...`
andlrc '16

@ dev-null Bah，我在codegolf.stackexchange.com/a/73323/17602中修复了它，但也忘了在这里做。

4

# MATL，23 24 28字节

``````8H6hhYs"G@ZA32:126m?6Mc
``````

``````8H6hhYs         % array [8,10,16]
"               % for each base
G             %   push input. Do nothing the first time
@             %   push base (8, 10 or 16)
ZA            %   convert from base to decimal. Takes implicit input the first time
32:126m       %   is result in acceptable range?
?             %   if so
6M          %     push result of base conversion again
c           %     convert to char
%   implicitly end if
% implicitly end for each
% implicitly display stack contents
``````

@David谢谢！我认为`D`在这种情况下有必要清空堆栈。但是你是对的，不是！谢谢！
Luis Mendo

1
@David我需要`' ':'~'`在下一个发行版中包含一个预定义的文字！
Luis Mendo

1
`32:126m`是个好主意！！

3

## Pyth，23 21 20 18字节

``````@rd\m.xCizd0[8T16
``````

``````@rd\•m.xCizd0[8T16    Implicit: z=input
m     d [8T16    Map the following lambda d over [8, 10, 16]:
.x                try:
izd              convert z from that base
C                                          and convert to char
0           except: return the number 0
@                     Filter that on presence in
rd\•                   strings from space to \x80 (the printable ASCII characters).
``````

2

# Jolf，26个字节

`````` fΜ‘Ci8iΗi’dpAHdh sH"[ -~]
``````

# 说明

`````` fΜ‘Ci8iΗi’dpAHdh sH"[ -~]
‘      ’                array containing
Ci8                     input as base 8
i                    input as base 10
Ηi                  input as base 16
Μ        d               mapped
pAH             with from char code
_f             d           filtered
_sH"[ -~]   with strings matching that.
``````

1

# Bash + GNU实用程序+ ascii，36

``````ascii \$1|tac|grep -Po '(?<=s as `).'
``````

`ascii`可以通过来安装在Ubuntu上`sudo apt-get install ascii`

1

# Javascript ES6，89个字符

``````s=>'0o,,0x'.split`,`.map(x=>(x+=s)>31&x<128&&String.fromCharCode(x)).filter(x=>x).join` `
``````

``````f=s=>'0o,,0x'.split`,`.map(x=>(x+=s)>31&x<128&&String.fromCharCode(x)).filter(x=>x).join` `
"31,47,69,7A,100,156,189,potaTo,5G,19".split`,`.map(f) == "1,' / G,E i,z,@ d,n,,,,"
``````

1

## Lua，147字节

``t={}for _,i in pairs({8,10,16})do x=tonumber(arg[1],i)x=x and x or 0 t[#t+1]=127>x and 19<x and string.char(x)or nil end print(table.concat(t," "))``

### 脱节和解释

``````t={}                        -- Initalise the array containing the chars to print
for _,i in pairs({8,10,16}) -- Iterate over the array {8,10,16}
do
x=tonumber(arg[1],i)      -- convert the input in base i to a number in base 10
x=x and x or 0            -- if the input wasn't a number, x is nil
-- use a ternary operator to set x in this case
t[#t+1]=127>x and 19<x    -- if x is the bytecode of a printable character
and string.char(x)or nil-- insert this character into t
end
print(table.concat(t," "))  -- concatenate the values in t with " " as separator
-- and print it``````

``for i=1,#table do --[[code here, use table[i] ]] end``

``for key,value do pairs(table) do --[[code here]] end``

1

# C（功能），76

• @anatolyg节省了2个字节。
• @luserdroog节省了5个字节。
``j,c;f(char*s){for(j=8;c=strtol(s,0,j);j=j*j/6)isprint(c)?printf("%c ",c):0;}``

anatolyg

`j*=j,j/=6`更明确地写为`j=j*j/6`
anatolyg

@anatolyg当然-谢谢！我巧言令色相结合运营商-有点像`j*=j/6`，但没有整数除法期间由于精度损失的工作

`j<20,`逗号运算符将放弃此操作的全部效果。
luser droog

@luserdroog是的-谢谢！
Digital Trauma

0

# 的JavaScript ES6，89 88个字节

``````n=>[..."0x+"].map(t=>String.fromCharCode(eval(`0\${t+n}`))).filter(k=>~k.search(/[ -~]/))
``````

``````n=>[..."0x+"].map(t=>String.fromCharCode(eval(`0\${t+n}`))).filter(k=>~k.search(/[ -~]/)).join` `
``````

@Neil Firefox似乎可以正常使用。

@Neil再次回到工作状态，重新工作...
Conor O'Brien

0

# R，84个字节

``````function(x){s=sapply;y=s(c(8,10,16),strtoi,x=x);cat(s(y[y%in%c(32:126)],intToUtf8))}
``````