29
\$\begingroup\$

Write a quine... from which every other character can be removed it still be a valid quine. You can specify whether to start removing characters at the first or second character.

Scoring criteria (add bonuses/penatly percentages together for total percentage):

  • Answers must be at least 4 characters long
  • Program must contain at least one alphabetical character in its source, so for example, 12345!@#$%^&*() is disqualified
  • +750% if the language used is not Turing-complete (I'm looking at you, HTML!)
  • -15% if the solution does not read its source from anywhere in any form
  • -20% if you can also keep only every 5th character and still form a quine

The score is measured by the number of characters in the first program.

Example (not real programs):

If 123456789abcdef and 13579bdf are both quines, the score is 15. Additionally, if 159d is also a quine, then the final score is 12.

This is code-golf, so lowest score wins.

\$\endgroup\$
16
  • 2
    \$\begingroup\$ @hosch250 The original program wouldn't be a quine because it wouldn't print those whitespaces. Same goes for unnecessary comments. \$\endgroup\$
    – Jwosty
    Mar 7, 2014 at 5:26
  • 1
    \$\begingroup\$ Yeah, I have never programed a quine before, and have no idea how to do it without reading the source code in C++. I have seen them in C++ before though! \$\endgroup\$
    – user10766
    Mar 7, 2014 at 5:37
  • 1
    \$\begingroup\$ You state: "-20% if you can also remove every 4 characters and still form a quine". But technically this is not what happens in your example. You mean you can do it a second time? \$\endgroup\$
    – mmumboss
    Mar 7, 2014 at 8:17
  • 4
    \$\begingroup\$ Are the bonuses additive or multiplicative? That is, if my program is 10 chars long and qualifies for both the -15% bonus and the -20% bonus, will its score be 10 * (1 - 0.15 - 0.2) = 6.5 or 10 * (1 - 0.15) * (1 - 0.2) = 6.8? I assumed the latter, but an explicit clarification would be nice. \$\endgroup\$ Mar 7, 2014 at 10:26
  • 1
    \$\begingroup\$ Wouldn't this be a Mandoline quine, not a Guillotine? Guillotines make one clean, generally fatal, cut and the head rolls away. Mandolines make with the many evenly spaced slices. :) \$\endgroup\$ Mar 7, 2014 at 21:45

12 Answers 12

25
\$\begingroup\$

PHP, 4 chars − 15% − 20% = 2.72 2.6 points

ABCD

Yes, PHP is a Turing-complete language. Nobody said I have to use any of its actual programming features. ;-)

Edit: Changed the score based on the clarification that bonuses are additive, not multiplicative.

\$\endgroup\$
4
  • \$\begingroup\$ This works in ASP, possibly. \$\endgroup\$ Mar 7, 2014 at 14:03
  • 2
    \$\begingroup\$ @n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ I give up. :P \$\endgroup\$
    – Jwosty
    Mar 8, 2014 at 4:35
  • 22
    \$\begingroup\$ Actually, use of PHP's actual programming features is discouraged. \$\endgroup\$
    – Rhymoid
    Mar 8, 2014 at 18:21
  • 3
    \$\begingroup\$ This is not a proper quine. Still a good answer, though \$\endgroup\$
    – MilkyWay90
    Apr 6, 2019 at 18:21
15
\$\begingroup\$

Python - 95

Great challenge. I thought this was pretty clever, and actually a legit solution!

00;"#";print(open(__file__).read())
0#;XpXrXiXnXtX(XoXpXeXnX(X_X_XfXiXlXeX_X_X)X.XrXeXaXdX(X)X)
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Nice! Note this technically doesn't work as-is since you end up deleting the newline when making the alternate quine. requires a tad bit of tweaking IOW \$\endgroup\$
    – Claudiu
    Mar 7, 2014 at 5:44
  • 3
    \$\begingroup\$ @Claudiu Well I guess it depends on whether OP considers newline a character. If so, you can just add a newline between each line. 96 chars \$\endgroup\$
    – qwr
    Mar 7, 2014 at 5:47
  • 1
    \$\begingroup\$ Of course a newline is a character... \$\endgroup\$
    – mbomb007
    Dec 13, 2016 at 21:28
14
\$\begingroup\$

TI BASIC 4 - 35% = 2.6

I might understand them wrong, but I think I am also eligible for the -15% and the -20% bonusses, meaning I have the lowest possible score.

I can write the program:

123i

which will output 123i where i is of course the imaginary unit. When you remove the 1st and the 3rd character all that remains is 2i which outputs 2i

\$\endgroup\$
5
  • \$\begingroup\$ Not quite... '12i' will output '12i' and '2' will output '2' for a minimum score of 1.95. \$\endgroup\$
    – intx13
    Mar 7, 2014 at 11:33
  • \$\begingroup\$ Actually, '2i' scores 1.3, and if the empty program is considered a quine, 'i' scores 0.65. \$\endgroup\$
    – intx13
    Mar 7, 2014 at 11:36
  • 4
    \$\begingroup\$ @intx13: "Answers must be at least 4 characters long." \$\endgroup\$ Mar 7, 2014 at 14:02
  • \$\begingroup\$ Ah, I missed that! \$\endgroup\$
    – intx13
    Mar 7, 2014 at 18:14
  • \$\begingroup\$ Beat me to it ;) \$\endgroup\$
    – Timtech
    Mar 8, 2014 at 0:40
11
\$\begingroup\$

Golfscript, 5 points

{hai}

is a function that, when executed, will run the (non-existing) function hai. It's not executed, however, but rather printed when the program ends - including the outer brackets. Removing each other character yields:

{a}

Lame, I know :-)

\$\endgroup\$
11
  • \$\begingroup\$ I believe you qualify for both bonuses, too: your program does not read its own source code, and {} is a quine too. \$\endgroup\$ Mar 7, 2014 at 10:21
  • \$\begingroup\$ @IlmariKaronen it's hard to tell what counts as reading own source code. Does unevaluating functions count? Does evaluating strings count? As for the other bonus - maybe it's just badly worded, but I read "remove every four characters" as "keep every fifth character", which would leave me with one bracket only (though {ab0} qualifies if 0 can be the one that's kept) \$\endgroup\$ Mar 7, 2014 at 10:40
  • \$\begingroup\$ It's indeed badly worded, but the example suggests it means "keep every fourth character". Anyway, as you note, {ab0} qualifies either way. \$\endgroup\$ Mar 7, 2014 at 10:44
  • \$\begingroup\$ It seems {hi} also works, will be shorter (4 chars), and will also qualify for all bonuses. (Seems the script {i evaluates to {i for some reason...) \$\endgroup\$
    – Claudiu
    Mar 7, 2014 at 16:59
  • \$\begingroup\$ @Claudiu {i produces an extra closing curly for me \$\endgroup\$ Mar 7, 2014 at 19:02
9
\$\begingroup\$

HQ9+ - 4 * 7.5 * 0.8 = 24 points

Q+++

Still a quine with every second character:

Q+

...and every fifth:

Q

Sorry, I couldn't resist. :)

\$\endgroup\$
7
\$\begingroup\$

HTML/Markdown, 4*7.5 = 30

HHHH

I admit this is lame, but it doesn't really go against any rule in the question. Except that HTML/Markdown may not be considered a real programming language.

\$\endgroup\$
7
  • \$\begingroup\$ I suppose I didn't specify that programs that can't be split any smaller aren't valid. Revising challenge... \$\endgroup\$
    – Jwosty
    Mar 7, 2014 at 5:38
  • \$\begingroup\$ @Jwosty: then "HHHH" in HTML would win. Note 5555 doesn't work because it has no alphabetic character \$\endgroup\$
    – Claudiu
    Mar 7, 2014 at 5:42
  • \$\begingroup\$ You need an alphabetic character. \$\endgroup\$
    – qwr
    Mar 7, 2014 at 5:43
  • \$\begingroup\$ @qwr: Forgot that when looking at GolfScript. Removed. \$\endgroup\$ Mar 7, 2014 at 5:44
  • \$\begingroup\$ Hmm... I suppose that this valid :P \$\endgroup\$
    – Jwosty
    Mar 7, 2014 at 5:50
5
\$\begingroup\$

!/bin/sh

I liked qwr's solution so much, I shamelessly made a port for POSIX shell. Please don't save it into a filename containing spaces.

: '#';cat $0

#c a t   $ 0

Start removing at character number 1, and count newlines as characters. The second quine is of course:

 #;a 0
cat $0

Please upvote qwr's answer instead of this one!

\$\endgroup\$
0
3
\$\begingroup\$

Bash, 23

Newline is a character!

Some messy comment work, so that when every other character starting from the first is removed, the comment becomes code and the code becomes a comment:

#cRaRtR R$R0R R#
cat $0

After every other character (including the new line) is removed:

cat $0 #ct$
\$\endgroup\$
4
  • \$\begingroup\$ it's not a quine if it reads its own source though. \$\endgroup\$
    – daniero
    Apr 13, 2014 at 14:58
  • \$\begingroup\$ @daniero "-15% if the solution does not read its source from anywhere in any form" implies that you are allowed to read the program's source (but you don't get the bonus) \$\endgroup\$
    – user16402
    Apr 13, 2014 at 15:39
  • \$\begingroup\$ @daniero oh i looked on wikipedia I suppose it is cheating... but it's code-golf \$\endgroup\$
    – user16402
    Apr 13, 2014 at 15:44
  • \$\begingroup\$ I always upvote cats! \$\endgroup\$ Apr 13, 2014 at 18:29
3
\$\begingroup\$

Vyxal, 8 bytes -15% = 6.8

` I,` I,

Try it Online!

Every other char

`I`I

Try it Online!

Explanation :

` I,`    # push ` I,`
      I  # quote and prepend
       , # print

`I`  # push `I`
   I # quote and prepend
     # implicit output
\$\endgroup\$
2
\$\begingroup\$

Brainf**k, 37 - 15% = 31.45

Abusing the Portable Brainfuck Interpreter

+A[B-C<D+E]F-GÿH<I<J<K<L<M<N<O[P.Q>R]

Start removing from the second character.

\$\endgroup\$
4
  • \$\begingroup\$ When i run this I get B-C<D+E]F-GÿH<I<J<K<L<M<N<O[P.Q>R] as output so it's lacknig some characters. \$\endgroup\$
    – Sylwester
    Mar 8, 2014 at 10:57
  • \$\begingroup\$ Is it Brainfuck, or a particular dialect of Brainfuck that only works on one interpreter? \$\endgroup\$
    – user253751
    Mar 8, 2014 at 10:57
  • \$\begingroup\$ @immibis It's regular (those capital letters can be spaces or symbols or anything). However, you must use the portable interpreter linked from the answer. \$\endgroup\$
    – Timtech
    Mar 8, 2014 at 12:28
  • 1
    \$\begingroup\$ The first part goes left until it finds the ÿ and the linked interpreter happens to store the code 5000 bytes before the start of the data tape. That's hardly portable Brainfuck. \$\endgroup\$
    – user253751
    Mar 8, 2014 at 12:40
2
\$\begingroup\$

Python 3, 145 94 bytes -15% : Score = 79.9

s ="'psr=i%nrt;(p'rsi n=t%(rs;%e%xse)c;(xsc[s11:::2  2']; p)r'i%nst)(#s#%#s#)";exec(s[1:: 2] )

Try it online!

every other char:

s='s=%r;print(s%%s);xcs1:2 ';print(s%s);xcs1:2 

Try it online!

How it works :

The ugly string is the blending of :

  • print('s =%r;exec(s[1::2 ] )'%s)#### for the normal quine
  • 's=%r;print(s%%s);xcs1:2 ';print(s%s) for the every-other-char quine

xcs1:2 is an annotation and doesn't throw any error as the part after the semicolumn can compile. Otherwise it would throw a SyntaxError and the program wouldn't run at all.

Python 3, with reading code source: 70 62 bytes

s ="p-r-i-n-t-(-*-o-p-e-n-(-_-_-f-i-l-e-_-_-)-)";exec(s[::2] )

Try it online!

every other char:

s=print(*open(__file__));xcs:2 

Try it online!

\$\endgroup\$
0
\$\begingroup\$

HQ9+T, - 4 * 0.8 = 3.2 points

qqqq

It's a valid quine (ish) and a quine every second and fifth char. I couldn't resist . . . .

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.