ASCII Reverse Quine

5

0

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.

Magic Octopus Urn

Posted 2017-06-20T14:02:46.620

Reputation: 19 422

@Mayube you should have no input to your program. – Magic Octopus Urn – 2017-06-20T14:10:24.290

Here's a conversion script for verification. – Martin Ender – 2017-06-20T14:11:44.767

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).

– Martin Ender – 2017-06-20T14:17:54.930

@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. – Magic Octopus Urn – 2017-06-20T14:18:32.947

@MartinEnder I thought that was standard for all quine challenges ._. – Magic Octopus Urn – 2017-06-20T14:19:24.413

Japt has a one byte solution with T too. – Jonathan Allan – 2017-06-20T14:19:27.033

@JonathanAllan It just occurred to me that Retina has two 1-byte solutions that aren't actually literal-only (T and ^ both work), but they still fail the proper quine rules (necessarily, because the a single-byte solution can't have a part of the code encode a different part). – Martin Ender – 2017-06-20T14:20:49.510

I was attempting to mitigate 1 byte quines with the "cannot use a palindromic character". It sat in the sandbox over the weekend, I wish you'd seen it then :(. Oh well, hopefully adding that proper quine part will handle the rest of the trivial answers. – Magic Octopus Urn – 2017-06-20T14:22:25.980

Oh... this is my question. – Magic Octopus Urn – 2018-03-27T23:29:27.777

Answers

8

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.

Martin Ender

Posted 2017-06-20T14:02:46.620

Reputation: 184 808