Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Julien Moutinho <julien.moutinho@g...>
Subject: Re: [Caml-list] Palindromic Quine
On Tue, Jan 29, 2008 at 12:23:45AM +0900, Keisuke Nakano wrote:
> A 'Palindromic Quine' code is now wanted by a shortest-code contest at:
>
>  http://golf.shinh.org/p.rb?Palindromic+Quine
>
> 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.

Quite a cheating palindromic Quine, but that's enough for my being satisfied.

% cat t.ml
(*/*)()=()open Sys let tel()=();;let fer=print_string executable_name in tel
let ni eman_elbatucexe gnirts_tnirp=ref tel;;()=()let tel syS nepo()=()(*\*)
% O=`cat t.ml`; mkdir -p "(*"; ocamlc -w a t.ml -o "$O"; "$O"
(*/*)()=()open Sys let tel()=();;let fer=print_string executable_name in tel
let ni eman_elbatucexe gnirts_tnirp=ref tel;;()=()let tel syS nepo()=()(*\*)
% wc t.ml
  2  16 154 t.ml

Explanation:
  It just calls [print_string Sys.executable_name]
  with an ad-hoc executable name.
Also, I've considered that ")(" and "/\" are palindromic.

Cheers,

        Julien Moutinho.