CTQUINE - Plant a Christmas Tree

no tags 

Evergreen trees are really wonderful. They were treasured by all civilisations of the Western world, from ancient Egiptian priests to Celtic druids in the British Isles. In the late Middle Ages a tradition of placing an evergreen tree at home for Christmas developed in Germany and spread throughout the Old and New World, reaching the Asia Pacific and America in the XIX-th century.

Surely, you must have noticed the sad fact that nowadays this global custom, however beautiful it may be, results in the death of millions of coniferous trees worldwide. Help us in our effort to restore the healthy balance. In the Christmas period, draw & plant your own tiny fir tree!

Since we are limited to text mode, there is little room for creative art, and solid, well built trees are definitely favoured. An ideal tree consists of several lines (at least 1) of the same length, consisiting of ASCII characters -- both whitespace ("spaces"), and non-whitespace ("relevant characters"). Counting from the top, the number of characters between the first and last relevant characters in a line (inclusive) is equal to 1, 1, 3, 1, 3, 5, 1, 3, 5, 7, 1, 3,... for consecutive lines. The line for which this distance is the largest begins and ends with relevant characters. All other lines contain exactly the same number of spaces to the left of the leftmost relevant character and to the right of the rightmost relevant character (this gives the ideal tree a nice, vertical trunk).

Please write a program which outputs a tree as close to an ideal tree as you can get, and keeps it as small as possible (such a tree has the largest chance of sprouting roots when planted). And it can hardly come as a surprise to you to learn that the source code of the program you submit has to be identical to the text it writes to output (character by character, there are no exceptions)!

Score

Your program will be judged as follows: if the program is not a quine (i.e. if it contains no relevant characters or outputs text different than its own source code) it will be judged as a Wrong Answer. Any other program will receive some number of penalty points depending on its size and quality as a tree (the fewer points, the better). One penalty point is given for every line of code used. 10 penalty points are given for a line without any relevant characters (how can you expect a broken tree to grow?). For non-empty lines, the position of the leftmost and rightmost relevant characters in the analyzed tree are compared with respect to corresponding positions in an ideal tree with the same number of lines. The squared differences in position between these two pairs of characters are added to the penalty score.

Technical note: a single newline character (ASCII 10) should be used to terminate all lines. ASCII characters 32 (space) and 9 (tab) are treated as single spaces, all other characters are considered relevant. Notice that the problem description doesn't penalise for left out or excessive spaces after the last relevant character of a line (but doesn't allow any difference between the source code and output text in this respect).

Example

C source code:
   ;
   ;
  ;;;
   ;
  main(
 )  {;
   ; 
  ; ;   
 /* */     
;return
   0
  ;;}

This code would be judged as Wrong Answer, since it isn't a valid quine. Were it a quine, it would receive 16 penalty points (12 for 12 lines, 4=22 additional penalty points for a misplaced rightmost relevant character in line 5).

Solutions to this problem may only be submitted in the following languages: C, C++, Pascal, Java, C#, Python, Haskell, OCaml, Brainf**k, Intercal.


hide comments
Mitch Schwartz: 2022-08-12 23:35:29

Thank you!

Robert Lewon: 2022-08-08 16:35:52

The list of available languages is fixed. All the previous submissions in forbidden languages have been disqualified.

Mitch Schwartz: 2022-07-21 16:20:08

The allowed language list at the bottom of the problem description seems very clearly targeted to exclude languages that can read their own source code, and I don't know why the "Include new languages" checkbox wasn't unchecked, but now seems like a good time to revise the language list. :) (I know very little Perl6/Raku so I can't speak to that offhand, but bc should obviously be removed (not for reading source but for being trivial), and I think several others.)

A similar thing happened in 2013 with AWK (gawk) and sed, and again in 2015 with Python nbc (no bytecode compilation), which admins may see from my submission history. (I don't recall which admin(s) I was in communication with when I reported the issue before, but if not for admin disqualification I would have disqualified those submissions myself, as the intention of leaving the solutions up was to make reviewing easier until the problem could be fixed.)

Last edit: 2022-07-22 19:47:25
Aditya Pande: 2015-02-19 11:14:42

A non quine will be judged WA

any other reason for getting WA
coz there's already penalty for changing the shape of the tree

edit: most probably not centering the tree gives WA

Last edit: 2012-06-19 12:40:48
[Trichromatic] XilinX: 2015-02-19 11:14:42

Done. And I e-mailed the problem setter and told him that.

.::Manish Kumar::.: 2015-02-19 11:14:42

I agree!

numerix: 2015-02-19 11:14:42

TEXT submissions should be disqualified ...

Piotr KÄ…kol: 2015-02-19 11:14:42

Pity, that language HQ9+ isn't available. ;-P


Added by:adrian
Date:2004-12-16
Time limit:17s
Source limit:30000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:BF C-CLANG C CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG C99 HASK ICK JAVA OCAML PAS-GPC PAS-FPC PYTHON PYPY PYPY3 PYTHON3
Resource:DASM Programming League 2004, problemset 4