Skip to main content

Questions tagged [code-generation]

For challenges where answers are expected to generate code.

Filter by
Sorted by
Tagged with
6 votes
3 answers
835 views

Golf an HQ9+ transpiler

There was a prior question about golfing an HQ9+ compiler that translates HQ9+ code into the language it is written in, but that was closed as a duplicate of the interpreter challenge because ...
Someone's user avatar
  • 1,620
13 votes
17 answers
3k views

Make Code Printing X without X

The challenge is simple: write a program which takes in some non-empty string \$n\$ consisting of only uppercase and lowercase ASCII letters, and outputs the code for a program (in the same language) ...
97.100.97.109's user avatar
19 votes
29 answers
3k views

Restricted Meta-Cat

Your challenge, should you choose to accept it, is to write a program in a language of your choice that, when given a string (limited to printable ASCII) as input, outputs a new program in the same ...
noodle person's user avatar
8 votes
3 answers
638 views

Expand Emmet HTML Abbreviations

Emmet is a text-editor and IDE plugin for writing HTML code using much fewer keypresses. You might think of it like a code-golfing HTML preprocessor. Its syntax is based on CSS selectors. Your ...
noodle person's user avatar
18 votes
24 answers
3k views

Meta-cat program

Write a program or function that takes input and outputs/returns a full program (in the same language) that outputs said input. Note that the input may contain any printable ASCII character or newline ...
Dadsdy's user avatar
  • 2,095
27 votes
12 answers
1k views

Increment, decrement, undo, peek

Write a program or function (hereafter "function") that returns or prints the source code of four new functions: Increment, decrement, undo, and peek. The initial function contains an ...
Jordan's user avatar
  • 10.1k
4 votes
1 answer
396 views

Convert 256-wrap brainfuck into 257-wrap brainfuck

Usually each cell in brainfuck has 256 states, which is not enough to tell whether input is EOF or a character (usually \xFF). To fix it we can add one more state ...
l4m2's user avatar
  • 24.8k
3 votes
0 answers
129 views

Hello Shue! (Robbers)

Cops thread (read first) Robbers, your task is to find a Shue program p that when given the cops input i, outputs a program <...
AnttiP's user avatar
  • 7,898
4 votes
2 answers
341 views

Hello Shue! (Cops)

Robbers thread In this cops-and-robbers challenge, your task is to write a program h that outputs "Hello Shue!". Next, you have to choose a string ...
AnttiP's user avatar
  • 7,898
12 votes
8 answers
1k views

Iterative Quine

Create a program which prints itself, followed by an additional program. This additional program should print the first program, itself, and then a third program. This continues until the nth program, ...
thejonymyster's user avatar
19 votes
2 answers
594 views

Counting and so on

Content You count numbers every day (I think), and most of you know how to count properly, the one next to 1 is 2, and the next ...
okie's user avatar
  • 1,807
15 votes
4 answers
715 views

Could you massage this stack for me?

Forth is one of the few non-esoteric stack-based languages. For this challenge, we will use a small subset of Forth, which simply executes a sequence of words in a linear fashion — without any ...
Maya's user avatar
  • 5,693
5 votes
2 answers
1k views

Generate the shortest regex to match these but not those [closed]

Challenge Given two lists of strings where each string is of length 50 and each list is also of length 50 generate the shortest regex you can that fully matches all the strings in the first list and ...
user197974's user avatar
  • 1,161
13 votes
9 answers
1k views

Optimize imnotdeadfish

Fluff After taking a look at deadfish, I decided it sucked, so I came up with a new (and easier) variant of it: imnotdeadfish. As with its predecessor, there are 4 commands and an accumulator which ...
Underslash's user avatar
  • 1,729
18 votes
12 answers
3k views

Make a polyglot generator

A polyglot is a program that runs in several languages. Your challenge is to: Choose at least two languages (Different versions count as different languages) Create a program or function that takes ...
emanresu A's user avatar
  • 39.1k
12 votes
4 answers
532 views

Shrinking Triangles

Write an infinite list of triangle codes, defined as code where the i-th line has i bytes for all lines, such that the i-th code generates (i-1)th code and has 1 more line than the (i-1)th code. The ...
l4m2's user avatar
  • 24.8k
12 votes
3 answers
506 views

Multiplying Quines

The program should start out with 2 separate files, here named "a" and "b". "a" and "b" should be what I am calling inverse quines: "a", when run, ...
blueberry's user avatar
  • 221
29 votes
10 answers
2k views

Help Stack Exchange transpose tables

Stack Exchange doesn't know how to transpose tables. Let's help. Given a markdown table, transpose it. Input assumptions: There will be at least two rows (including header) and two columns Either all ...
Adám's user avatar
  • 30.6k
13 votes
9 answers
1k views

Peel away the layers - Robbers

This is the Robbers thread. For the Cops challenge, see here As the robbers, your job is to crack the cops' answers. Choose an uncracked, unsafe cop answer and attempt to figure out which languages, ...
caird coinheringaahin g's user avatar
28 votes
14 answers
3k views

Peel away the layers - Cops

In this cops-and-robbers challenge, robbers must crack cop answers by finding out which languages the cops used. This is the Cops thread. For the Robbers' challenge, see here Cops, you are to write a ...
caird coinheringaahin g's user avatar
8 votes
6 answers
917 views

TTT: Turing Text Tape

Introduction Ah, INTERCAL... As much as I'd like encourage everyone to Try it Online, text output is just painful. According to the docs it uses the "Turing Text Model". While an... ...
mindoverflow's user avatar
  • 1,053
2 votes
0 answers
181 views

Predictor Generator [closed]

Write a program that when given a string \$S\$, it generates a program of the same language as itself. The generated program, when given a continuous substring of \$S\$, should predict the next ...
user avatar
17 votes
3 answers
2k views

How divisible are you?

You are to create a program which, when given a positive integer \$n\$, outputs a second program. This second program, when run, must take a second positive integer \$x\$ and output one of two ...
caird coinheringaahin g's user avatar
3 votes
9 answers
909 views

Lazy brainfuck programmer [closed]

Background Joe is working on his new Brainfuck answer on Codegolf. The algorithm he's using to solve the challenge is a bit complicated, so Joe came up with idea of simplifying his Brainfuck notation ...
Kamila Szewczyk's user avatar
39 votes
18 answers
8k views

Generate Brainfuck for the numbers 1–255

Write a program that, for the numbers 1 through 255, prints out BF code that will produce the given number in some byte of the array, plus a newline. For example, the first four lines of the output ...
Mason's user avatar
  • 2,155
6 votes
2 answers
327 views

Generate Aheui Number

Make a Number Expression is related : actually, it is also about Aheui. But it just made number expression, but this made real Aheui code. Aheui is esolang written in only Korean character. Because ...
LegenDUST's user avatar
  • 969
18 votes
9 answers
2k views

Write the longest period iterating quine bounded by 500 bytes

Your job is to create the longest period iterating quine, where the length of each program in the sequence is bounded by 500 bytes. That is, if you repeat the following steps: Start with your ...
Christopher King's user avatar
8 votes
1 answer
450 views

Generate an expression yielding near-equidistributed result

Create a program (any language) which, given positive integer m, outputs a valid C expression that: Uses a single variable x ...
fgrieu's user avatar
  • 615
11 votes
5 answers
1k views

Compose two Brainfuck programs

Given 2 brainfuck code snippets A and B, output some brainfuck code C which has the same ...
l4m2's user avatar
  • 24.8k
35 votes
27 answers
4k views

Code-generator with unique characters

Challenge Your task is to write a piece of code that outputs another piece of code. That code must in turn output yet another code until the final code outputs the integer 1. The chain ends the first ...
Stewie Griffin's user avatar
25 votes
35 answers
4k views

Produce a m*n table in HTML

Input : Two decimal integers m and n that respectively give the number of rows and columns of the table. ...
potato's user avatar
  • 369
4 votes
4 answers
319 views

Program Sequence Generator

Your challenge is to implement a cyclic Program Sequence Generator (PSG) in a language of your choice. Given a language, L, a PSG in L is a program in L that outputs a PSG in L. Some properties of a ...
Vaelus's user avatar
  • 609
30 votes
14 answers
3k views

Generate TeX to typeset Sierpinski Triangle Fractal

Challenge Write code that outputs TeX (LaTeX) math-equation code (given below) that will typeset Sierpinski Triangle Fractal of 5 levels. Shortest code wins. Details TeX (and friends like LaTeX, ...
Vitaliy Kaurov's user avatar
30 votes
79 answers
3k views

Script that outputs a script that prints a given input

Write a piece of code that takes a string as input, and outputs a piece of code in the same language that, when run, will output the initial input string. It must be able to handle any combination of ...
quartzic's user avatar
  • 417
6 votes
2 answers
723 views

Generate all halting Smallfuck programs of length n

Your task is to write a program that, given a number n, returns a list of all valid, halting Smallfuck programs of length n, in any order. Actually, we're using a variation of Smallfuck called F2, ...
Esolanging Fruit's user avatar
4 votes
1 answer
354 views

Insert a simulated Ken Thompson virus into a program

A Ken Thompson virus is a virus that infects your compiler and other programs. Since it infects all your tools, you can not detect it without using tools from before the virus was introduced. Your ...
Christopher King's user avatar
40 votes
87 answers
6k views

Generate ;# code

Related to: Make a ;# interpreter In the above linked challenge the task was to create an interpreter for the esoteric language ;#. The ...
kalsowerus's user avatar
  • 2,024
18 votes
9 answers
627 views

Make Wise Numbers

Wise is a simple bitwise language I designed a while back. It is based around Python's bitwise operations. It has several operations most of these are the same or very similar to the equivalent ...
Wheat Wizard's user avatar
  • 98.9k
26 votes
8 answers
2k views

Convert braces to Right Hand Brace (Sad Brace)

Right hand brace is a style of code bracketing in which curly braces and semicolons are all aligned to a single point on the right side of a a file. Generally, this is considered bad practice, for ...
ATaco's user avatar
  • 10.9k
2 votes
7 answers
945 views

Kolmogorov Complexity Meta Golfer

Mike Bufardeci (Pyth) - 175 bytes Leo (Retina) - 175 bytes devRicher (Lua) - 182 bytes Peter Taylor (CJam) - Waiting for clarification Lyth (C++11) - Waiting for clarification Edit: Several ...
Julian Lachniet's user avatar
21 votes
13 answers
2k views

Output a program that outputs a program ... that outputs PPCG

Challenge: Write a code that, when executed will output the source code of a second program that can be executed in another language. The second program should output the source code of a third ...
Stewie Griffin's user avatar
16 votes
9 answers
816 views

Grow Till It's 2017

In this challenge you'll be building a program that grows as it traverses through the ages… Until it's 2017. Challenge Whenever this challenge description says “program”, you can ...
user2428118's user avatar
  • 2,056
15 votes
2 answers
336 views

Solve a Stack State Diagram

A stack state diagram shows how the values on one stack are changed into the other. For example, this is a stack state diagram: 3 0 2 1 0 This means that there ...
Esolanging Fruit's user avatar
21 votes
14 answers
3k views

Cheating Cyclic Quine

Concept Write a program that outputs code in its programming language. That code, when executed, must output the original program. Rules Since this is a cheating quine, you can read the original ...
anna328p's user avatar
  • 6,396
25 votes
15 answers
986 views

Transpile WordMath

We've all seen those online "maths hax" that look like this: Think of a number, divide by 2, multiply by 0, add 8. And, by magic, everyone ends up with the ...
FlipTack's user avatar
  • 14.7k
13 votes
22 answers
2k views

Prepend line number comments [closed]

Definitions: A line is a possibly empty sequence of characters terminated by a “newline character.” A “newline character” is a character that cannot be a component of the aforementioned character ...
Esolanging Fruit's user avatar
31 votes
7 answers
2k views

Three polyglots, two period-two quines, and one code-golf challenge

Produce a program A such that running it in language A produces Program B, and running program A in language B produces program C. Program B, when run in language B produces Program A, and running ...
noɥʇʎԀʎzɐɹƆ's user avatar
18 votes
9 answers
954 views

The meta-polyglot quine

In my time on PPCG, I've noticed that quine problems and polyglot problems are quite popular. Also, meta-solutions to problems, that is, scripts which generate a program which is the solution to a ...
Pavel's user avatar
  • 9,377
27 votes
2 answers
838 views

Hyper about quines

Inspired by Hyperprogramming: N+N, N×N, N^N all in one. Thanks to @MartinEnder and @trichoplax for their help in the sandbox. Definitions Hyperquines Define a hyperquine of order n as a quine-...
Dennis's user avatar
  • 210k
17 votes
2 answers
395 views

Given a truth table, output a Stackylogic program that satisfies it

Stackylogic is a programming language I made up in a previous challenge: Run Stackylogic. Read that post for full details and examples, but here is how it works paraphrased: Stackylogic takes ...
Calvin's Hobbies's user avatar