Questions tagged [code-generation]
For challenges where answers are expected to generate code.
96 questions
12
votes
11
answers
1k
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
8k
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:
...
6
votes
3
answers
850
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
673
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
583
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
137
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
355
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
603
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 ...
15
votes
4
answers
729
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 ...
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 ...