This page is still under construction.

Parts of this page are still being built. What you see may change.

HQ0-9+-INCOMPUTABLE?!

Time limit1sMemory limit1024 MB

Summary
Construct an HQ0-9+-INCOMPUTABLE?! program of at most 10000 commands whose final buffer equals a given target string.
Level

Hard10 of 10

Topics
String, Simulation, Implementation, Brute force
Solved
No attempts yet

Problem

HQ9+ is an esoteric programming language specialized for certain tasks. For example, printing "Hello, world!" or writing a quine (a program that prints itself) could not be any simpler. Unfortunately, HQ9+ does not do very well in most other situations. This is why we have created our own variant of the language, HQ0-9+-INCOMPUTABLE?!.

An HQ0-9+-INCOMPUTABLE?! program is a sequence of commands, written on one line without any whitespace (except for the trailing newline). The program can store data in two memory areas: the buffer, a string of characters, and the accumulator, an integer variable. Initially, the buffer is empty and the accumulator is set to 0. The value of the buffer after executing all the commands becomes the program's output.

HQ0-9+-INCOMPUTABLE?! supports the following commands:

commanddescription
h, Happends helloworld to the buffer
q, Qappends the program source code to the buffer (not including the trailing newline)
0-9replaces the buffer with n copies of its old value. For example, '2' doubles the buffer
+increments the accumulator
-decrements the accumulator
i, Iincrements the ASCII value of every character in the buffer
n, Napplies ROT13 to the letters and numbers in the buffer (for letters ROT13 preserves case; for digits we define ROT13(d) = (d + 13) mod 10)
c, Cswaps the case of every letter in the buffer; does not change other characters
o, Oremoves all characters from the buffer such that their index, counted from the end, is a prime or a power of two (or both); the last character has index 1 (which is a power of 2)
m, Msets the accumulator to the current buffer length
p, Premoves all characters from the buffer such that their index is a prime or a power of two (or both); the first character has index 1 (which is a power of 2)
u, Uconverts the buffer to uppercase
t, Tsorts the characters in the buffer by their ASCII values
a, Areplaces every character in the buffer with its ASCII value in decimal (1 to 3 digits)
b, Breplaces every character in the buffer with its ASCII value in binary (exactly eight '0'/'1' characters)
l, Lconverts the buffer to lowercase
e, Etranslates every character in the buffer to l33t using the following table:```
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789
48(03=6#JXLM 09Q257UVW%Y2 a6<d3f9hijk1m^0p9r57uvw*y2 O!ZEA$G/B9
| `?` | removes 47 characters from the end of the buffer (or everything if it is too short) |
| `!` | removes 47 characters from the beginning of the buffer (or everything if it is too short) |

As you can see, HQ0-9+-INCOMPUTABLE?! is much more powerful than HQ9+. Demonstrate this by writing and submitting an HQ0-9+-INCOMPUTABLE?! program that outputs 로그인하면 보이는 값.

Constraints

Your program must be at most 10000 commands long. The accumulator is unbounded (it can store an arbitrarily large integer). After each command, the buffer must be at most 10000 characters long. To prevent code injection vulnerabilities, during the execution of your program the buffer must never contain non-alphanumeric characters, i.e. characters other than A-Z, a-z, and 0-9. Should this happen, the program fails with a runtime error, and your submission will be rejected.

Hint

programoutput
h5!rld
QCqqcQQCq
q23q23q23q23q23q23q23
h?hhelloworld
H2Ohlwolheo
h4opollwldwlhe
hintccfkrsvzzz
q18Nd41Ad41Ad41Ad41Ad41Ad41Ad41Ad41A
3QAh518165104helloworld
Qb0101000101100010
opaque094QU3
h1Qt1Qdehhllloortw
H9999(error: buffer size exceeded 10000)
quine(error: buffer contains "|")
LMAO(empty output)

Examples1

  1. Example 1

    Input
    
    
    Expected output
    HQ09INCOMPUTABLE