5
\$\begingroup\$

Okay, so everyone is familiar with the ASCII-table, correct? I'd hope so. I've been going to that site for my asciitable reference for as long as I can remember needing one. We'll be doing some fun source-code manipulating using the ASCII keyspace.


The Task

Your task is to write a program that, when executed, prints the source code with the ASCII decimal of each character reversed. What exactly does this mean? Say this was my sourcecode:

#;

The ASCII of this would be:

(35)(59)

After knowing this, we should reverse each to get what the program should output:

(53)(95)

Which means for a program of #; we need to output:

5_

Constraint 1 (Important)

However, like in most challenges, there's a hefty catch. All characters in your source code must be within the printable ASCII range. If the reverse of the ASCII character does NOT lie within 32-128, the character can't be used. For any character with an ASCII code greater than 100, you will reverse it and use the first two digits. For instance:

d = 100 => 001 => 00 => \0 => non-ASCII => invalid

Another example, of a valid 3-digit ASCII reverse:

{ = 123 => 321 => 32 => ' ' => valid

If this is unclear, see the "Conversion" part below, if the character is not listed there on the left, it cannot be in your source code.


Constraint 2 (Important)

In addition to this constraint, the user must also use at least one non-palindromic ASCII character. This means that if you want to use 7, which is ASCII 55 and converts directly TO 7, you will have a 2-byte answer at minimum.


Constraint 3

Your program will take no input, as this is a quine challenge. In addition to this, it must adhere to the specifications of a proper quine defined here:

http://meta.codegolf.stackexchange.com/questions/4877/what-counts-as-a-proper-quine


The Concrete Specification

Printable ASCII Set (32-126):

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

Conversions:

  => 23 => (not valid)
! => 33 => ! (valid)
" => 43 => + (valid)
# => 53 => 5 (valid)
$ => 63 => ? (valid)
% => 73 => I (valid)
& => 83 => S (valid)
' => 93 => ] (valid)
( => 04 => (not valid)
) => 14 => (not valid)
* => 24 => (not valid)
+ => 34 => " (valid)
, => 44 => , (valid)
- => 54 => 6 (valid)
. => 64 => @ (valid)
/ => 74 => J (valid)
0 => 84 => T (valid)
1 => 94 => ^ (valid)
2 => 05 => (not valid)
3 => 15 => (not valid)
4 => 25 => (not valid)
5 => 35 => # (valid)
6 => 45 => - (valid)
7 => 55 => 7 (valid)
8 => 65 => A (valid)
9 => 75 => K (valid)
: => 85 => U (valid)
; => 95 => _ (valid)
< => 06 => (not valid)
= => 16 => (not valid)
> => 26 => (not valid)
? => 36 => $ (valid)
@ => 46 => . (valid)
A => 56 => 8 (valid)
B => 66 => B (valid)
C => 76 => L (valid)
D => 86 => V (valid)
E => 96 => ` (valid)
F => 07 => (not valid)
G => 17 => (not valid)
H => 27 => (not valid)
I => 37 => % (valid)
J => 47 => / (valid)
K => 57 => 9 (valid)
L => 67 => C (valid)
M => 77 => M (valid)
N => 87 => W (valid)
O => 97 => a (valid)
P => 08 => (not valid)
Q => 18 => (not valid)
R => 28 => (not valid)
S => 38 => & (valid)
T => 48 => 0 (valid)
U => 58 => : (valid)
V => 68 => D (valid)
W => 78 => N (valid)
X => 88 => X (valid)
Y => 98 => b (valid)
Z => 09 => (not valid)
[ => 19 => (not valid)
\ => 29 => (not valid)
] => 39 => ' (valid)
^ => 49 => 1 (valid)
_ => 59 => ; (valid)
` => 69 => E (valid)
a => 79 => O (valid)
b => 89 => Y (valid)
c => 99 => c (valid)
d => 001 => (not valid)
e => 101 => (not valid)
f => 201 => (not valid)
g => 301 => (not valid)
h => 401 => ( (valid)
i => 501 => 2 (valid)
j => 601 => < (valid)
k => 701 => F (valid)
l => 801 => P (valid)
m => 901 => Z (valid)
n => 011 => (not valid)
o => 111 => (not valid)
p => 211 => (not valid)
q => 311 => (not valid)
r => 411 => ) (valid)
s => 511 => 3 (valid)
t => 611 => = (valid)
u => 711 => G (valid)
v => 811 => Q (valid)
w => 911 => [ (valid)
x => 021 => (not valid)
y => 121 => (not valid)
z => 221 => (not valid)
{ => 321 =>   (valid)
| => 421 => * (valid)
} => 521 => 4 (valid)
~ => 621 => > (valid)

ESOLANGS: If you're using a custom CODEPAGE and wish to use the CODEPAGE definition as the ASCII table, I'll allow it. But you must be thorough in your explanation of why the characters are enumerated as they are (and it must make sense based on an existing code-page diagram). According to this 31/96 (32%) conversions are invalid, therefore it should follow that for a codepage of 255 characters, a consecutive range of 96 characters can be considered as "printable ASCII" if, and only if, it results in 31 (or 32%) or more of those characters being invalid.


This is , lowest byte-count wins.

\$\endgroup\$
  • \$\begingroup\$ @Mayube you should have no input to your program. \$\endgroup\$ – Magic Octopus Urn Jun 20 '17 at 14:10
  • \$\begingroup\$ Here's a conversion script for verification. \$\endgroup\$ – Martin Ender Jun 20 '17 at 14:11
  • \$\begingroup\$ Do our proper quine rules apply for this challenge? Otherwise, some languages might have solutions that are effectively literal-only answers (e.g. T in CJam prints 0, because T happens to be a variable that is initialised to zero). \$\endgroup\$ – Martin Ender Jun 20 '17 at 14:17
  • \$\begingroup\$ @MartinEnder I've changed constraint 2 slightly, but I figured a conversion table would be a solid specification of what exactly can and cannot be done. \$\endgroup\$ – Magic Octopus Urn Jun 20 '17 at 14:18
  • \$\begingroup\$ @MartinEnder I thought that was standard for all quine challenges ._. \$\endgroup\$ – Magic Octopus Urn Jun 20 '17 at 14:19
7
\$\begingroup\$

CJam, 24 bytes

{s"_~"+{isW%Y60c~ic}%}_~

Try it online!

Prints:

 3+;>+" 23NIb-Tc>2c4I4;>

A fairly standard generalised quine. The only character we could have used that is forbidden is <, which we get with 60c~ instead.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.