Questions tagged [code-generation]
For challenges where answers are expected to generate code.
98 questions
16
votes
11
answers
2k
views
A million and one constants
When code golfing, it can be useful to write numbers succinctly. This challenge involves using a source language to generate code for a target language. For the submission to be valid, it must ...
8
votes
1
answer
393
views
Sequence of programs that prints the next one with length growth being equal to π
Challenge
You must produce an infinite sequence of programs \$P_0, P_1, P_2,\$ … such that each program \$P_n\$, when run, prints the exact source code of \$P_{n+1}\$ and then halts.
Each program \$...
13
votes
12
answers
2k
views
Bespoke numbers
Introduction
Bespoke is an esoteric programming language I created in January 2025, where the commands are encoded into the lengths of words in the program. For example, ...
33
votes
26
answers
9k
views
Print 4 billion if statements
Recently (okay, December 2023, I'm a little late) there's been a meme going around about a program checking if a 32-bit unsigned integer is even or odd using four billion if statements:
...
7
votes
3
answers
922
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 ...
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) ...
20
votes
31
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 ...
8
votes
3
answers
732
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 ...
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 ...
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 ...
6
votes
1
answer
658
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 but ...
3
votes
0
answers
155
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 <...
4
votes
2
answers
394
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 ...
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, ...
19
votes
2
answers
648
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 ...