develooper Front page | perl.fwp | Postings from January 2002

Re: solutions

Thread Previous | Thread Next
Peter Makholm
January 28, 2002 16:20
Re: solutions
Message ID: writes:

> -p $_ x=1&~$.&split$&while aeiouy=~/.?/g                    40 eugen

I didn't know the x-operator. Pretty smart and I'm actually think I
understands whats going on.

$_ gets 'repeated' 0 or 1 time by the x= based on the value of the
rest. I didn't thought of binary negation myself but used +1 for the
same effect (one char more but can be suffixed). The ? ine the matchs
makes sure you also splits on the empty string (a lot of times) to
calculate the length of the string, right?

> -p for$v(aeiouy=~/./g){$_ x=1&~eval"$.|~y///c|y/$v//"}      54 jason
> -nl 1&eval join qw(//|y/ $.|y/a e i o u y //c)or print      54 makho
> -nl $x=$.%2;map{$x^=4*2**index aeiouy,$_}/./g;$x||print     55 turn

Three quite different solutions. I really like Stephens solution iot
counts each of the wovels individually much nicer than anything I
thought of.

Når folk spørger mig, om jeg er nørd, bliver jeg altid ilde til mode
og svarer lidt undskyldende: "Nej, jeg bruger RedHat".
                                -- Allan Olesen på dk.edb.system.unix

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About