По-русски  English

YAPC::Russia::Golf 2008

Rules  Solutions 

YAPC::Russia::Golf is a contest for solving the task with shortest code, which happened during the conference YAPC::Russia «May Perl» 2008 on 17 and 18 May of 2008 in Moscow.

The winner is a person who writes a programme that contains minimal number of non-space symbols. It is possible to use any option of the perl interpreter (such as -l, -n, -p), but those symbols (together with hyphens) are added to the total number of symbols in the programme. Path to perl in a sheebang is not calculated, but the options (if they present there) are.

Task 1

It is easy to obtain with the help of regular expression that a number may be divided by 4:

#!perl
 while(<>) {
     if( /[02468][048]$/ || /[13579][26]$/ || /^[048]/ ) {
         print "yes\n";
     } else {
         print "no\n";
     }
 }

Try to write a code without arithmetic, bitwise or string operators and without the operator x (only control statements and regular expressions), the code must check whether the number may be divided by 11. STDIN gets natural numbers less than 1080. For each number print yes if it is dividable, and no otherwise.

Input example Output example
4no
33yes
910095859353843713526357940283  yes
9117517no

Task 2

First line of STDIN is a number N, others compose the block of equally long strings which consist of spaces and symbols #. String length and their number are both not more than 200.

Find the maximal number of # symbols that fit into any rectangle with the square exactly equal to N and such that each cell of it is situated within the given block.

Input example

Output example
14

Note. No rectangle 1 × 25 fits, we does not count them; rectangles 25 × 1 cover 13 cells maximum; and a rectangle 5 × 5 that covers 14 symbols is shown below: