Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Palindromic Quine
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-02-08 (13:39)
From: Keisuke Nakano <ksk@m...>
Subject: Re: [Caml-list] Palindromic Quine
The shortest code contest 'Palindromic Quine' is over.
The result is found at:

Finally I could find the shortest code with 199 bytes:

"k\"",let rec(!)n?(q=String.make 1(Char.chr 34))s k=print_char 
(q^s^q^q^k^q).[abs n];!(n-1)s k in!99"99!ni k s)1-n(!;]n sba[.) 
q^k^q^q^s^q(rahc_tnirp=k s))43 rhc.rahC(1 ekam.gnirtS=q(?n)!(cer  

It is an acceptable solution for the contest though the code
execution ends with an exception 'index out of bounds'.

There may exist a palindromic Quine code shorter than this code.
Please try to find it if you're interested in.


Keisuke Nakano <ksk _at_>

On 2008/01/29, at 0:23, Keisuke Nakano wrote:
> A 'Palindromic Quine' code is now wanted by a shortest-code contest  
> at:
> The code should be a Quine, which prints its own code without reading
> its source file. Additionally, the code should be palindromic, which
> reads the same forward as it does backward. Shorter code is better.
> Lots of programming languages are available including OCaml, of  
> course.
> Please submit your palindromic Quine to the above contest if you  
> find it.
> The deadline is Thursday, 7 February 2008, 16:46:39, GMT.
> All submitted programs will be revealed after the deadline.
> At present the shortest code in OCaml has 205 bytes.