-
Notifications
You must be signed in to change notification settings - Fork 0
/
SDQR.py
1 lines (1 loc) · 7.61 KB
/
SDQR.py
1
p="#include <stdio.h>^nP#include <string.h>^nP#include <stdlib.h>^nPchar * desanitize(const char *str) { char *output = malloc(strlen(str)); char *output^current^pos = output; for (char *ptr = (char*) str; *ptr != '^bP0'; ptr++) { char output^char = *ptr; if (*ptr == '^' && ptr[2] == 'C' && ptr[3] == '-') { if (ptr[1] == 'b') output^char = '^bP^bP'; else if (ptr[1] == 'q') output^char = '^qP'; else if (ptr[1] == 'n') output^char = '^bPn'; ptr += 3; } *output^current^pos++ = output^char; } return output; } int main(void) { FILE *file = fopen(^qPSDQR.cpp^qP, ^qPw^qP); fprintf(file, ^qP%s^qP, desanitize(^qP#include <iostream>^nC-#include <regex>^nC-#include <fstream>^nC-std::string desanitize(std::string str) { std::string tmp1 = std::regex^replace(str,std::regex(^qC-^qCP^qC-),^qC-^bC-^qC-^qC-); std::string tmp2 = std::regex^replace(tmp1,std::regex(^qC-^nCP^qC-),^qC-^bC-n^qC-); return std::regex^replace(tmp2,std::regex(^qC-^bCP^qC-),^qC-^bC-^bC-^qC-); } int main() { std::ofstream outfile; outfile.open(^qC-SDQR.cs^qC-); outfile << desanitize(^qC-class MainClass { static void Main(string[] args) { System.IO.File.WriteAllText(^qCPSDQR.lisp^qCP, ^qCP(defun replace-all (string part replacement-char &key (test #'char=)) (with-output-to-string (out) (loop with part-length = (length part) for old-pos = 0 then (+ pos part-length) for pos = (search part string :start2 old-pos :test test) do (write-string string out :start old-pos :end (or pos (length string))) when pos do (write-char replacement-char out) while pos))) (defun desanitize (string) (replace-all (replace-all (replace-all string ^qC#^nL^qC# #^bC#linefeed) ^qC#^qL^qC# #^bC#^qC#) ^qC#^bL^qC# #^bC#^bC#)) (with-open-file (stream ^qC#next^qC# :direction :output :if-exists :supersede) (format stream ^qC#~d^qC# (desanitize ^qC#p=^qL^RWP^qL; p2=p.replace(^qL^bLu005e^qL,^qL^bLu005f^qL).replace(^qL^bLu005f^bLu0062^bLu0050^qL,^qL^bL^bL^qL).replace(^qL^bLu005f^bLu006e^bLu0050^qL,^qL^bLn^qL).replace(^qL^bLu005f^bLu0071^bLu0050^qL,^qL^bL^qL^qL).replace(^qL^bLu005f^bLu0052^bLu0057^bLu0050^qL,p); f=open(^qLSDQR.c^qL,^qLw+^qL); f.write(p2); f.close(); print(^qL@qP[1;38;5;231m[Self-Documenting Quine Relay][22;39m [90m~[39m [38;5;224mj[39m[38;5;224mm[39m[38;5;230mo[39m[38;5;230mo[39m[38;5;230mr[39m[38;5;194me[39m[38;5;194m3[39m[38;5;194m4[39m[38;5;195m.[39m[38;5;195mg[39m[38;5;195mi[39m[38;5;189mt[39m[38;5;189mh[39m[38;5;189mu[39m[38;5;225mb[39m[38;5;225m.[39m[38;5;225mi[39m[38;5;224mo[39m@qP[90m...[39m [2m->[22m [1m[38;5;217m[Python][39m[22m [2m->[22m [38;5;229mC[39m [2m->[22m [90m...[39m [2m->[22m [38;5;219mLisp[39m [2m->[22m [38;5;217mPython[39m [2m->[22m [90m...[39m@qPCurrent language: [38;5;217mPython[39m. Next language: [38;5;229mC[39m.@qPWrote [38;5;231mSDQR.c[39m to current directory.@qP[1;93m[Compile][22;39m gcc SDQR.c -o SDQR-c [1;38;5;231mor[22;39m clang SDQR.c -o SDQR-c@qP[1;93m[Run][22;39m ./SDQR-c@qP^qL.replace(^qL^bLu0040^bLu0071^bLu0050^qL,^qL^bLn^qL))^qC#))) (format t ^qC#~d^qC# (desanitize ^qC#^nL[1;38;5;231m[Self-Documenting Quine Relay][22;39m [90m~[39m [38;5;224mj[39m[38;5;224mm[39m[38;5;230mo[39m[38;5;230mo[39m[38;5;230mr[39m[38;5;194me[39m[38;5;194m3[39m[38;5;194m4[39m[38;5;195m.[39m[38;5;195mg[39m[38;5;195mi[39m[38;5;189mt[39m[38;5;189mh[39m[38;5;189mu[39m[38;5;225mb[39m[38;5;225m.[39m[38;5;225mi[39m[38;5;224mo[39m^nL[90m...[39m [2m->[22m [1m[38;5;219m[Lisp][39m[22m [2m->[22m [38;5;217mPython[39m [2m->[22m [90m...[39m [2m->[22m [38;5;153mC#[39m [2m->[22m [38;5;219mLisp[39m [2m->[22m [90m...[39m^nLCurrent language: [38;5;219mLisp[39m. Next language: [38;5;217mPython[39m.^nLWrote [38;5;231mSDQR.py[39m to current directory.^nL[1;93m[Run][22;39m python3 SDQR.py^nL^nL^qC#)) ^qCP.Replace(^qCP^qC#^qCP, ^qCP^bCP^qCP^qCP).Replace(^qCP^nC#^qCP,^qCP^bCPn^qCP).Replace(^qCP^bC#^qCP,^qCP^bCP^bCP^qCP)); System.Console.Write(^qCP^nC#[1;38;5;231m[Self-Documenting Quine Relay][22;39m [90m~[39m [38;5;224mj[39m[38;5;224mm[39m[38;5;230mo[39m[38;5;230mo[39m[38;5;230mr[39m[38;5;194me[39m[38;5;194m3[39m[38;5;194m4[39m[38;5;195m.[39m[38;5;195mg[39m[38;5;195mi[39m[38;5;189mt[39m[38;5;189mh[39m[38;5;189mu[39m[38;5;225mb[39m[38;5;225m.[39m[38;5;225mi[39m[38;5;224mo[39m^nC#[90m...[39m [2m->[22m [1m[38;5;153m[C#][39m[22m [2m->[22m [38;5;219mLisp[39m [2m->[22m [90m...[39m [2m->[22m [38;5;158mC++[39m [2m->[22m [38;5;153mC#[39m [2m->[22m [90m...[39m^nC#Current language: [38;5;153mC#[39m. Next language: [38;5;219mLisp[39m.^nC#Wrote [38;5;231mSDQR.lisp[39m to current directory.^nC#[1;93m[Package][22;39m sudo apt install sbcl^nC#[1;93m[Run][22;39m sbcl --script SDQR.lisp^nC#^qCP.Replace(^qCP^nC#^qCP,^qCP^bCPn^qCP) + ^qCP^bCPn^qCP); } }^qC-); outfile.close(); std::cout << desanitize(^qC-^nCP[1;38;5;231m[Self-Documenting Quine Relay][22;39m [90m~[39m [38;5;224mj[39m[38;5;224mm[39m[38;5;230mo[39m[38;5;230mo[39m[38;5;230mr[39m[38;5;194me[39m[38;5;194m3[39m[38;5;194m4[39m[38;5;195m.[39m[38;5;195mg[39m[38;5;195mi[39m[38;5;189mt[39m[38;5;189mh[39m[38;5;189mu[39m[38;5;225mb[39m[38;5;225m.[39m[38;5;225mi[39m[38;5;224mo[39m^nCP[90m...[39m [2m->[22m [1m[38;5;158m[C++][39m[22m [2m->[22m [38;5;153mC#[39m [2m->[22m [90m...[39m [2m->[22m [38;5;229mC[39m [2m->[22m [38;5;158mC++[39m [2m->[22m [90m...[39m^nCPCurrent language: [38;5;158mC++[39m. Next language: [38;5;153mC#[39m.^nCPWrote [38;5;231mSDQR.cs[39m to current directory.^nCP[1;93m[Package][22;39m sudo apt install mono-mcs^nCP[1;93m[Compile][22;39m mcs -out:SDQR-C#.exe SDQR.cs^nCP[1;93m[Run][22;39m mono SDQR-C#.exe^nCP^qC-) << std::endl; }^qP)); printf(^qP%s^bPn^qP, desanitize(^qP^nC-[1;38;5;231m[Self-Documenting Quine Relay][22;39m [90m~[39m [38;5;224mj[39m[38;5;224mm[39m[38;5;230mo[39m[38;5;230mo[39m[38;5;230mr[39m[38;5;194me[39m[38;5;194m3[39m[38;5;194m4[39m[38;5;195m.[39m[38;5;195mg[39m[38;5;195mi[39m[38;5;189mt[39m[38;5;189mh[39m[38;5;189mu[39m[38;5;225mb[39m[38;5;225m.[39m[38;5;225mi[39m[38;5;224mo[39m^nC-[90m...[39m [2m->[22m [1m[38;5;229m[C][39m[22m [2m->[22m [38;5;158mC++[39m [2m->[22m [90m...[39m [2m->[22m [38;5;217mPython[39m [2m->[22m [38;5;229mC[39m [2m->[22m [90m...[39m^nC-Current language: [38;5;229mC[39m. Next language: [38;5;158mC++[39m.^nC-Wrote [38;5;231mSDQR.cpp[39m to current directory.^nC-[1;93m[Compile][22;39m g++ --std=c++11 SDQR.cpp -o SDQR-c++^nC-[1;93m[Run][22;39m ./SDQR-c++^nC-^qP)); }"; p2=p.replace("\u005e","\u005f").replace("\u005f\u0062\u0050","\\").replace("\u005f\u006e\u0050","\n").replace("\u005f\u0071\u0050","\"").replace("\u005f\u0052\u0057\u0050",p); f=open("SDQR.c","w+"); f.write(p2); f.close(); print("@qP[1;38;5;231m[Self-Documenting Quine Relay][22;39m [90m~[39m [38;5;224mj[39m[38;5;224mm[39m[38;5;230mo[39m[38;5;230mo[39m[38;5;230mr[39m[38;5;194me[39m[38;5;194m3[39m[38;5;194m4[39m[38;5;195m.[39m[38;5;195mg[39m[38;5;195mi[39m[38;5;189mt[39m[38;5;189mh[39m[38;5;189mu[39m[38;5;225mb[39m[38;5;225m.[39m[38;5;225mi[39m[38;5;224mo[39m@qP[90m...[39m [2m->[22m [1m[38;5;217m[Python][39m[22m [2m->[22m [38;5;229mC[39m [2m->[22m [90m...[39m [2m->[22m [38;5;219mLisp[39m [2m->[22m [38;5;217mPython[39m [2m->[22m [90m...[39m@qPCurrent language: [38;5;217mPython[39m. Next language: [38;5;229mC[39m.@qPWrote [38;5;231mSDQR.c[39m to current directory.@qP[1;93m[Compile][22;39m gcc SDQR.c -o SDQR-c [1;38;5;231mor[22;39m clang SDQR.c -o SDQR-c@qP[1;93m[Run][22;39m ./SDQR-c@qP".replace("\u0040\u0071\u0050","\n"))