Quine with prime sourcecode character distribution constraints

5

  1. Your program should take no input, and no network or other connections.
  2. Your program should output it's sourcecode.
  3. The sourcecode must consist of 3 types of characters: Numeric (0-9), Alpha (a-z|A-Z) and symbols !(0-9|a-z|A-Z). Constraints for the distribution of characters is:
    • 3.1. Every neighbouring characters with equal character-type makes a character-group.
    • 3.2. Each character-group length in bytes must be a prime-number (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, ...)
    • 3.3. The total number of character-groups of each character-type must be a neighbouring (but not equal) fibonacci sequence number. For example: 3 groups of numbers, 5 groups of alpha, 8 groups of symbols.
    • 3.4. A character-group of one charater-type cannot be adjacent to another character-group of the same character-type, because that will create one bigger group instead.

Example valid sourcecode (regarding character distribution, it does however not output it's sourcecode):

"."."."aa321'","/hithere' 12345678901,.,.,12345,.,

Character distribution in the example: 2 groups of Alpha. 3 group of numeric. 5 groups of other characters. The numbers 2, 3 and 5 are neighbouring numbers in the fibonacci sequence.

This is code-golf, good luck have fun!

Plarsen

Posted 2014-01-18T10:22:31.047

Reputation: 1 740

You might want to disallow trivial solutions like any numeric literal in golfscript before it's too late. – John Dvorak – 2014-01-18T10:29:23.737

1I believe the somewhat boring quine 12 would be legal in J, GolfScript, etc under these rules (2 being a prime number and 1 being a fibonacci number). – FireFly – 2014-01-18T10:29:46.533

The sourcecode must consist of all 3 types of characters, so it is atleast 6 character-groups – Plarsen – 2014-01-18T10:31:12.753

neighbours in the fibonacci sequence – Plarsen – 2014-01-18T10:33:08.760

so, 0 doesn't count as a fibonacci number? – John Dvorak – 2014-01-18T10:35:40.603

It does, but the code must contain all three types of characters. So rule 3 invalidates 0 groups of one character-type. – Plarsen – 2014-01-18T10:37:13.917

Oh, I see, "Your source code must consist of 3 types of characters". I read that as a partitioning of the characters rather than a requirement in itself, at first. – FireFly – 2014-01-18T10:39:41.567

do 1 and 1 count as neighbouring fibonacci numbers? Or, are we even allowed to use "neighbouring or equal" character group counts? Also, does 1 count as a prime? – John Dvorak – 2014-01-18T10:50:43.940

If there is 1 group of any character-type, that is the 1 neighbouring 2 in the fibonacci sequece, so 1 and 1 does not count as neighbouring numbers in the fibonacci sequence in this code-golf. Atleast 6 character-groups. 1 does not count as a prime. – Plarsen – 2014-01-18T10:58:03.183

Answers

2

PHP, some other languages - 12 bytes

22ab,,22,,22

PHP will print out the source code if it is not wrapped in some tag.

This is actually the smallest possible answer to the question. The smallest prime number is 2, and the smallest distinct fibonacci numbers are 1, 2, and 3. 3 + 2 + 1 = 6. 6 * 2 = 12

See a run here: http://ideone.com/0NDA8A

Justin

Posted 2014-01-18T10:22:31.047

Reputation: 19 757

3

Golfscript, 21 15 characters

11{'aa.~' }aa.~

After removing all NOPs, their images, and the leading 11, this becomes the quine

{`'.~'}.~

reading: block(string(dup, eval)); dup; eval.

Now to shoot for the stars (20 characters - the minimum for 2-3-5) or even galaxies (12 characters - the absolute minimum) I've taken a short stop at Alpha Centauri B to refuel, now I'm drifting through intergalactic medium. Thanks, Goldbach's conjecture.

Live: http://golfscript.apphb.com/?c=MTF7J2FhLn4nMTE7fWFhLn4K

John Dvorak

Posted 2014-01-18T10:22:31.047

Reputation: 9 048

@Plarsen shaved off six characters. One more to go, then I believe I'll hit the rock bottom for golfscript. – John Dvorak – 2014-01-18T13:48:03.393

oh man! I could never imagine that was even possible! – Plarsen – 2014-01-18T14:12:12.183

2

Befunge 98 - 16 bytes

<@,*+982aa,,kd$"

This works only if your interpreter interprets line-wrap as adding a single space. This one works otherwise:

<@,*+982aa,,kd "

Character groups:

<@,*+ 5 chars, symbols
982   3 chars, numbers
aa    2 chars, alpha
,,    2 chars, symbols
kd    2 chars, alpha
$"    2 chars, symbols

So the fibonacci numbers are 1 (numbers), 2 (alpha), and 3 (symbols)

Justin

Posted 2014-01-18T10:22:31.047

Reputation: 19 757

2

Windows Command Script - 12 bytes (+ free folder bonus)

md  12##56##

Since every command is echoed by default, it's just a matter of finding the shortest command.

Robert Sørlie

Posted 2014-01-18T10:22:31.047

Reputation: 1 036