5
1
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.)
1@vihan1086 Nope. This was discussed in the sandbox. Taking an input and generating the quine is completely different. The program you're golfing isn't required to be a quine, but is rather the generator program/function. – mbomb007 – 2015-07-29T20:39:23.827
4The answer to the previous question doesn't take much modification (I managed it with a Levenshtein distance of 7) to get an answer to this one. – Peter Taylor – 2015-07-29T20:57:58.413
1@PeterTaylor Good for you. Not everyone will find it so easy. Maybe try a different language. – mbomb007 – 2015-07-29T21:49:32.643
1Should the generator and the quine programs be in the same language? – randomra – 2015-07-29T21:59:25.243
@randomra Yes. Clarification added. – mbomb007 – 2015-07-30T14:08:06.133
I still maintain that this is not a duplicate. This was discussed in the sandbox, and I think it's different enough. Just because Peter Taylor is using an esoteric programming language, where it's easy for him to alter his existing program to fit the requirements, doesn't mean it's so easy in any other language. – mbomb007 – 2015-07-30T14:09:17.080
Also notice that the "duplicate" question is a code-challenge (but this is code-golf), and ALSO only has one answer (and with a score of 0). Give other people a chance to answer in a different language. – mbomb007 – 2015-07-30T14:11:14.207
@Jwosty "The resulting programs should all be distinct." – mbomb007 – 2015-07-30T20:55:40.643