in reply to Golf Challenge - does $x and $y fit into the same slot on @z?

25

#! perl -slw use strict; my @z = ( 1, 3, 27, 38 ); while( my ($x,$y) = split/,/,<DATA> ) { # 1 2 # 1234567890123456789012345 print "YES!\n" if @z==grep$x<=$_==$y<=$_,@z; } __END__ 4, 5 0, -1 100, 100 10, 27 3, 27

Examine what is said, not who speaks.

Replies are listed 'Best First'.
Re: Re: Golf Challenge - does $x and $y fit into the same slot on @z?
by gjb (Vicar) on Dec 28, 2002 at 01:03 UTC

    23

    #! perl -slw use strict; my @z = ( 1, 3, 27, 38 ); while( my ($x,$y) = split/,/,<DATA> ) { # 1 2 # 1234567890123456789012345 print "YES!\n" if @z==grep$x>$_==$y>$_,@z; } __END__ 4, 5 0, -1 100, 100 10, 27 3, 27 3, 3
    Okay, this is not exactly fair on my part, credit goes to BrowserUK.

    -gjb-

      It's fair enough. Once you pick an approach, golf is all about wiggling tokens to get a few more characters left out.

      Makeshifts last the longest.

      20
      #! perl -slw use strict; my @z = ( 1, 3, 27, 38 ); while( my ($x,$y) = split/,/,<DATA> ) { # 1 2 # 12345678901234567890 print "YES!\n" if !grep$x>$_!=$y>$_,@z; } __END__ 4, 5 0, -1 100, 100 10, 27 3, 27 3, 3