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 n
.
Description of Output Program:
The output program needs to be a program that, when run, ... will output a program... that will output a program... etc, until the n
th program is the original (first) output program. So this is, in a way, a modular quine. That's how I think of it, anyway.
The resulting programs should all be distinct.
Example:
Input: 2
Program: modulus_quine(n)
Output: P
→ Q
→ P
→ ...
Scoring:
This is code-golf, so shortest code (for the generating program) wins.
Brownie points (-0 bytes, +1 thumbs up?) are given to anyone whose generating program IS their modular quine. This is where your program takes the input and outputs the first modular quine in the sequence, which outputs the next, etc. The resulting output programs must not prompt the user for input (until it gets back to the generator.)