We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Meta Cat Program
This is my SECOND programming problem I've written. yay. I guess. 5anz (talk)
Given an input, a Meta Cat Program outputs a program that outputs the original input. Both programs (The Meta Cat Program and the output of it) must be in the same language. For example, Python cannot print JavaScript code. I mean, it definitely can, but then it wouldn't be a Meta Cat Program. Well, unless it outputs a Polyglot, but we're getting too technical, and we're missing the point
Below is a diagram (that I made in MS paint) that explains a bit how this works, because I'm not confident in my ability to explain things.
This is also kind of a combination of a Cat Program and a print("Hello, World!") program, and unlike those, this can actually be somewhat useful.
Implementations
Add an implementation in your own language if possible.
1+
1##,"1<11++#(|11"+""*++"*"";;11"+""*+""*++";/";11+"*""*+""++;/11+1<"//"\<#//";\";\\1+"//"\<#+++"<1"+""1+""**+*+;)1#
1nteger
SET inp
WHILE int > 0
PNT 1347310624
PNT int / 100 + 48
PNT int / 10 % 10 + 48
PNT int % 10 + 48
PNT 10
SET inp
END
><>
i1+:?!v1-'0'o>: ?v'o'o
>';'o;!^-1oo'1+'<
Brainfuck
+++++++++[>++++++++++<-]+>[<+>>+<-]>+++>>+++++++++[>+++++<-]>[<+<+<<+>>>>-]<<+>-->,[<<<<<.>.>.>>>[<.>-]<<.>>,]
C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
int main() {
char* string = NULL;
size_t length = 0;
int c;
while ((c = fgetc(stdin) != EOF) {
char* new_string = (char*) realloc(string, length + 1);
if (!new_string) {
free(string);
return EXIT_FAILURE;
}
string = new_string;
string[length] = c;
length++;
}
printf("#include <stdio.h>\n"int main() {printf(\"");
for (size_t i = 0; i < length; i++) {
printf("\\%02x", string[i]);
}
printf("\");}");
free(string);
}
C++
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
int main() {
std::stringstream sstream;
std::cin >> sstream.rdbuf();
std::string string = sstream.str();
std::cout << "#include <iostream>\nint main(){std::cout << \"";
std::cout << std::hex;
for (char c : string) {
std::cout << "\\x" << std::setw(2) << std::setfill('0') << (int) c;
}
std::cout << "\";}";
}
Free2Edit
gcwsp*p0ws-1p+p1wepopcgcwe
Python
#actually programmed this at school.
outOut = input()
print("out = \"\"")
for char in outOut:
print("out += chr(" + str(ord(char)) + ")")
print("print(out)")
Septem Lingua
@import stdin from process
let t<-stdin.read()
for i in t do
print "print ascii_decode(",ascii_encode(i),"),end<-\"\""
end
