Front page | perl.fwp |
Postings from January 2002
My Unorthodox/Artistic entry
Thread Previous
|
Thread Next
From:
Eugene van der Pijll
Date:
January 29, 2002 08:48
Subject:
My Unorthodox/Artistic entry
Message ID:
20020129164801.GC22878@ruunat.phys.uu.nl
Andrew.Savige@ir.com schreef op 28 januari 2002:
> ====================================
> Supremely Unorthodox/Artistic Prizes
> ====================================
>
> I will give advance notice, at least:
> Eugene (77 char solution)
> Keith (74 char solution)
> BooK (your gs solution, you know the one)
> should definitely participate!
After seeing Keiths solution, I have given up hope of winning this, but
if anyone is interested:
My nicest solution was this one:
#!/usr/bin/perl -p
$_ x=1&~eval$..join'__|y _y',_,a,e,i,o,u,Y,'
__c'
The string that gets evaluated for the first line of the file is:
"1___|y _ya__|y _ye__|y _yi__|y _yo__|y _yu__|y _yY__|y _y\n__c"
The first term in this string is the line number, followed by three
underscores. As underscores are allowed in numeric constants, this
evaluates to just the line number.
The 7th term, "y _yY__" counts the number of y's and Y's in the line. As
the line was guaranteed to be in lower case, this is equivalent to
counting the number of y's. The other terms count both y's and one other
vowel. When the number of y's is even, and the count of y's and a's is
even, the number of a's is also even. I could also have counted all
vowels individually, but then I should have written them as
a,e,i,o,u,'y' , as an unquoted y is interpreted as the transliteration
operator.
The important thing here is the choice of the y/// delimiters. Other
possible solutions of the same length are:
#!/usr/bin/perl -p
$_ x=1&~eval$..join'*//|y/y',_,a,e,i,o,u,Y,'
//c'
and
#!/usr/bin/perl -p
$_ x=1&~eval$..join"##
|y#y",_,a,e,i,o,u,Y,'
##c'
Of course, all these solutions can easily be shortened by one character:
#!/usr/bin/perl -p
$_ x=1&~eval join'__|y _y',$.,a,e,i,o,u,Y,'
__c'
However, I only noticed that when I started writing this post. I
abandoned this approach when I saw that Rick Klement was at 69, a full 8
strokes under my score.
Eugene
Thread Previous
|
Thread Next