Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions tagged [code-generation]

For challenges where answers are expected to generate code.

5
votes
1answer
305 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 ...
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 ...
35
votes
27answers
3k 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 ...
22
votes
30answers
3k 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. ...
5
votes
4answers
256 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
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, ...
28
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 ...
6
votes
2answers
419 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, ...
4
votes
1answer
288 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 ...
34
votes
66answers
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 ...
18
votes
9answers
565 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 ...
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 ...
2
votes
7answers
806 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 changes ...
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 ...
16
votes
9answers
748 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
251 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 ...
25
votes
15answers
845 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 ...
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 ...
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 ...
18
votes
9answers
723 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 ...
28
votes
2answers
665 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-...
17
votes
2answers
299 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 ...
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 ...
3
votes
3answers
495 views

Do not repeat yourself

Inspired by this challenge Given a number m, output a program that prints out the string Do not repeat yourself. Now for the ...
-3
votes
3answers
556 views

No Quine Built In? No Problem! [closed]

Are you tired of languages with built in quining techniques? Your challenge, should you choose to accept it, is to add a built-in quine feature to the language of your choice. Task Given some ...
1
vote
1answer
244 views

Meta Obfuscate a String [closed]

There are numerous reasons for trying to obfuscate input. These include preventing decompiling, and being a nuiscance. With this in mind your challenge should your choose to accept it is to write a ...
7
votes
5answers
625 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 ...
65
votes
18answers
9k 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 ...
31
votes
11answers
2k 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 ...
19
votes
18answers
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 ...
10
votes
4answers
451 views

Write a Semiquine

Suppose you have 2 languages, A and B. A string s is a semiquine in ...
34
votes
55answers
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: ...
21
votes
7answers
883 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 ...
-6
votes
2answers
297 views

Stop Internet Warming! [closed]

Task Write a program that will output another distinct program, and so on, while using as few distinct characters (and as few bytes) as possible. For example, program 1 should output program 2, and ...
18
votes
4answers
761 views

Growing Quine Sequence

You are to write a sequence of 10 programs p1 p2 ... p10 that satisfy the following properties: pK prints ...
25
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 ...
24
votes
3answers
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, ...
1
vote
1answer
525 views

Escape control characters in a C string

C/C++ use double quotes "" for making string literals. If I want the double-quote itself, or certain other characters, to appear in the string, I have to escape ...
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. ...
12
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 ...
28
votes
2answers
827 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 ...
5
votes
3answers
725 views

Quit Whining; Start Quining

Goal: Write a function or program that, given an integer n, will output a program in the same language that is a quine with a period of ...
5
votes
3answers
362 views

Quine permutation group [duplicate]

Write a program or function which, when run, outputs another program or function which is valid in the same language as the original program, and which itself will output another program or function ...
14
votes
2answers
913 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 ...
3
votes
6answers
830 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 ...
1
vote
1answer
103 views

Pythy Finite Ordinals [duplicate]

Write a program in any language that takes a single natural number n as input and generates a Pyth program that, in turn, produces, using nested lists, the nested set given by S(n), where: S(0) = ∅ ...
31
votes
6answers
2k 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 ...
18
votes
2answers
927 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 ...
6
votes
2answers
477 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 ...
11
votes
4answers
723 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 ...