develooper Front page | perl.golf | Postings from August 2002

Re: First posts of some famous golfers

Thread Previous | Thread Next
From:
Stefan `Sec` Zehl
Date:
August 28, 2002 03:21
Subject:
Re: First posts of some famous golfers
Message ID:
20020828102109.GA6849@matrix.42.org
Moin,

On Wed, Aug 28, 2002 at 03:19:20PM +1000, Andrew.Savige@ir.com wrote:
> En op 28 augustus 2002 sprak Sec:
> > Finding (and printing) all words (from stdin) with all of a set
> > of given letters (on the command line, for simplicity) appearing
> > once in the first 10 characters of the word, and containing no
> > duplicates in the first 10 characters.
> 
> Some examples would make this specification clearer.

Uuuh. It was really late, yesterday. - I tried hard to make it clear, an
now I see that all I created was this german like moster sentence %)

- The file on stdin is a wordlist, i.e. /^[\w][-a-z]*$/
- Word has to have at least 10 characters.
- The following rules apply to only the first 10 characters:
* case is insignficant
* no duplicate letters
* each of the letters on the commandline appears once

> Does the following example match the specification?

> #!perl -n
> BEGIN{$x=pop}
> length($x)-(@z=substr($_,0,10)=~/[$x]/g)||print

nice try :)

> When I run:
[...]
> it prints:
> 
> abcdefghijklmnopqrst

Yes.

> abc

No, too short.

> abcdefxyzdabc

No, Position 4 == Position 10 [d]

CU,
    Sec
-- 
Usenet II -- because it's time for October

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About