# Mandoline quine

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. • @hosch250 The original program wouldn't be a quine because it wouldn't print those whitespaces. Same goes for unnecessary comments. Commented Mar 7, 2014 at 5:26 • 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! – user10766 Commented Mar 7, 2014 at 5:37 • 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? Commented Mar 7, 2014 at 8:17 • 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. Commented Mar 7, 2014 at 10:26 • 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. :) Commented Mar 7, 2014 at 21:45 ## 12 Answers ## 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. • This works in ASP, possibly. Commented Mar 7, 2014 at 14:03 • @n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ I give up. :P Commented Mar 8, 2014 at 4:35 • Actually, use of PHP's actual programming features is discouraged. Commented Mar 8, 2014 at 18:21 • This is not a proper quine. Still a good answer, though Commented Apr 6, 2019 at 18:21 ## 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 • Not quite... '12i' will output '12i' and '2' will output '2' for a minimum score of 1.95. Commented Mar 7, 2014 at 11:33 • Actually, '2i' scores 1.3, and if the empty program is considered a quine, 'i' scores 0.65. Commented Mar 7, 2014 at 11:36 • @intx13: "Answers must be at least 4 characters long." Commented Mar 7, 2014 at 14:02 • Ah, I missed that! Commented Mar 7, 2014 at 18:14 • Beat me to it ;) Commented Mar 8, 2014 at 0:40 # 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)  • 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 Commented Mar 7, 2014 at 5:44 • @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 – qwr Commented Mar 7, 2014 at 5:47 • Of course a newline is a character... Commented Dec 13, 2016 at 21:28 ## 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 :-) • I believe you qualify for both bonuses, too: your program does not read its own source code, and {} is a quine too. Commented Mar 7, 2014 at 10:21 • @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) Commented Mar 7, 2014 at 10:40 • It's indeed badly worded, but the example suggests it means "keep every fourth character". Anyway, as you note, {ab0} qualifies either way. Commented Mar 7, 2014 at 10:44 • 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...) Commented Mar 7, 2014 at 16:59 • Commented Mar 7, 2014 at 19:02 ## 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. :) # 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. • I suppose I didn't specify that programs that can't be split any smaller aren't valid. Revising challenge... Commented Mar 7, 2014 at 5:38 • @Jwosty: then "HHHH" in HTML would win. Note 5555 doesn't work because it has no alphabetic character Commented Mar 7, 2014 at 5:42 • You need an alphabetic character. – qwr Commented Mar 7, 2014 at 5:43 • @qwr: Forgot that when looking at GolfScript. Removed. Commented Mar 7, 2014 at 5:44 • Hmm... I suppose that this valid :P Commented Mar 7, 2014 at 5:50 # !/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


# 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$

• it's not a quine if it reads its own source though. Commented Apr 13, 2014 at 14:58
• @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)
– user16402
Commented Apr 13, 2014 at 15:39
• @daniero oh i looked on wikipedia I suppose it is cheating... but it's code-golf
– user16402
Commented Apr 13, 2014 at 15:44
• I always upvote cats! Commented Apr 13, 2014 at 18:29

# Vyxal, 8 bytes -15% = 6.8

 I, I,


Try it Online!

## Every other char

II


Try it Online!

## Explanation :

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

I  # push I
I # quote and prepend
# implicit output


## 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.

• 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. Commented Mar 8, 2014 at 10:57
• Is it Brainfuck, or a particular dialect of Brainfuck that only works on one interpreter? Commented Mar 8, 2014 at 10:57
• @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. Commented Mar 8, 2014 at 12:28
• 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. Commented Mar 8, 2014 at 12:40

# 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!

# 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 . . . .