The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [code-generation]

For challenges where answers are expected to generate code.

Filter by
Sorted by
Tagged with
109
votes
47answers
32k views

Program that creates larger versions of itself (quine-variant)

You are to write a program that will output source code that is Larger than the original program (character wise) Will print another program larger than itself when run (i.e. the new program is also ...
68
votes
18answers
10k views

Rube Goldberg Hello World

For this golf, you will need to use more than one language. The task A Rube Goldberg machine is a contraption that takes an enormous number of complicated steps in order to execute a very simple ...
37
votes
61answers
5k views

Generate 100 Java Tuple classes

Write a script that writes to standard output, or your language's equivalent, 100 lines of (valid) Java code that begins with: ...
36
votes
73answers
5k 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 ...
35
votes
27answers
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 ...
34
votes
15answers
7k 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 ...
34
votes
13answers
3k views

1-up your average quine

A 1-up quine is a program which is very similar to a quine. The one major difference is that instead of printing itself once, when n copies of the program are concatenated, the result prints the ...
32
votes
7answers
1k 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 ...
31
votes
6answers
3k views

Make the largest infinity that you can!

The ordinal number system is a system with infinite numbers. A lot of infinite numbers. So many infinite numbers that it literally does not have an infinity to represent its own infiniteness. The ...
30
votes
14answers
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, ...
29
votes
72answers
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 ...
28
votes
2answers
903 views

Convert Brainfuck to MarioLANG

MarioLANG is a two-dimensional programming language where the source code resembles a Super Mario Bros. level. Furthermore, its instruction set is very similar to Brainfuck's. This means that ...
27
votes
2answers
729 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-...
26
votes
10answers
3k views

Chaining Programs

Challenge In this challenge, you will be writing the first program, p1, of an infinite sequence of programs, in which running pn outputs/generates program pn+1. When concatenating the first n >= 2 ...
26
votes
7answers
2k views

Generating Brainf*** NOPs

Sometimes when writing brainfuck code, you feel the need to make it longer than needed to encourage debugging. You could do it by just plopping a >< in there, ...
26
votes
8answers
1k 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 ...
25
votes
15answers
882 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 ...
25
votes
6answers
3k views

Big big numbers

Whilst trying to golf several of my answers, I've needed to write large integers in as few characters as possible. Now I know the best way to do that: I'll be getting you to be writing this program. ...
22
votes
30answers
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. ...
21
votes
7answers
911 views

Generate Programs in Increasing size

In this challenge, you will write a program which outputs a program which is the double the length of the original program. The outputted program should output a new program a program double its ...
19
votes
20answers
2k views

Write a Metaquine

A metaquine is a program which is not a quine, but whose output, when run as a program in the same language, is a quine. The goal of this challenge is to write a metaquine. This is code-golf, so ...
19
votes
8answers
1k views

Generalized Quine Generator

The Challenge In this challenge, you specify a source language S and a target language T. Your task is to write the following ...
18
votes
11answers
1k 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 ...
18
votes
4answers
793 views

Growing Quine Sequence

You are to write a sequence of 10 programs p1 p2 ... p10 that satisfy the following properties: pK prints ...
18
votes
9answers
576 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 ...
18
votes
9answers
763 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 ...
18
votes
2answers
995 views

String to Image

A bit of background: When I first learned about Brainf*ck, one of the first things I did was to write a Java application that would take in a string and create a, somewhat, optimized program to print ...
18
votes
4answers
2k views

Convert Fractran into Brainfuck

Background Fractran is an esoteric Turing-complete programming language invented by John Conway. A Fractran program consists of an ordered list of fractions. The program starts by taking a single ...
17
votes
13answers
2k views

Create a FizzBuzz compiler

Welcome to the world of compiler golf. Your task is to write a program that generates another program to play a variant of FizzBuzz on spec. Your compiler Write a compiler that generates variants of ...
17
votes
2answers
956 views

Compile Regexes

In this task you have to write a program that reads a regular expression and generates another program that outputs whether an input string is accepted by that regular expression. The output must be a ...
17
votes
2answers
326 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 ...
16
votes
7answers
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 ...
16
votes
9answers
764 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 ...
15
votes
2answers
923 views

Translate RoboCritters into Brainf***

RoboCritters (etymology) is a brand new esoteric programming language (don't bother searching for it, I just invented it). It's a variant of Brainfuck (BF), slightly more complex than the usual ...
15
votes
2answers
265 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 ...
14
votes
6answers
1k views

Fibonacci program lengths

Write a program with length n that outputs another program whose length is the next Fibonacci number after n. The new program must do the same thing - output another program whose length is the next ...
14
votes
5answers
970 views

Make any number by repeatedly adding 2 numbers

You are given a machine with two 16-bit registers, x and y. The registers are initialized x=1...
13
votes
11answers
1k views

A Program that Prints Programs

Challenge Your goal is to write a program that prints another program. That printed program should print another program, and the new program should print another program, until the end. Rules Each ...
12
votes
17answers
2k views

Generate /* line number comments */

Your task is to write a program (or function) that will take a string as input and append text to the beginning of every line that satisfy the following rules: The text appended must contain the line ...
11
votes
8answers
936 views

Generate a Brainf_ck program that outputs a string of given length

Your friend is trying to break into a vault that has a peculiar locking system: it requires a certain number of gentle knocks in a particular spot. Your friend discovered the number (which is in the ...
11
votes
4answers
799 views

Encoding an URL in brainfuck

Inspired by this question, your goal today is to encode an URL in brainfuck. My browser has been hacked! The location bar has been turned into a brainfuck interpreter. I need a program that turns an ...
10
votes
16answers
1k views

Code golf for the lazy

Your goal in this code golf is to take two strings, language and code (if the golfed code you wrote for this is multiline, then ...
10
votes
5answers
1k views

Compose two Brainfuck programs

Given 2 brainfuck code snippets A and B, output some brainfuck code C which has the same ...
10
votes
4answers
464 views

Write a Semiquine

Suppose you have 2 languages, A and B. A string s is a semiquine in ...
8
votes
5answers
676 views

Golf me an HQ9+ Compiler [duplicate]

Your task is "simple" should you choose to accept it. Write an HQ9+ compiler in a language of your choice. HQ9+ has four commands (as you may be able to tell) H prints "Hello, World!" Q prints out ...
8
votes
3answers
780 views

Self-shortening Prime Tester

Let's get right in to it. Your challenge is to make a program that does these things depending on its input: If the input is a number, output "Prime" if the number is a prime number and "Not prime" ...
8
votes
1answer
662 views

Create self-extractor script (relaxed rules)

This is the target language-relaxed version of Generate a self-extractor application Create a program in any language, that takes an arbitrary binary input, and generates a valid program (also in any ...
6
votes
7answers
1k views

Convert Brainfuck to a Non-Golfing Language

Input: Any Brainfuck program. This includes brainfuck programs with comments such as +++COMMENT[>+++<-].. Output: A program in one of the below languages ...
6
votes
2answers
507 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, ...
6
votes
2answers
538 views

Implement multiplication by a constant with addition and bit shifts

While looking at the ARM instruction set, you notice that the ADD instruction has the so-called "Flexible second operand", which can be abused for quick ...