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 ...
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, ...
7
votes
3
answers
921
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
12
votes
3
answers
576
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, ...
13
votes
9
answers
2k
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, ...
9
votes
6
answers
985
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... ...
24
votes
19
answers
26k
views
99 ways to say "I love you"
Inspired by this blog post.
Write a program that outputs 99 distinct programs (in the same language) that output the string I love you.
How the programs are ...
3
votes
9
answers
964
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 ...
7
votes
2
answers
429
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 of ...
8
votes
1
answer
488
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 ...
37
votes
32
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 ...
4
votes
4
answers
368
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 ...
30
votes
79
answers
4k
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 ...
4
votes
1
answer
391
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 ...
18
votes
9
answers
726
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 ...
2
votes
7
answers
1k
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 ...
16
votes
9
answers
907
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 ...
22
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 ...