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

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-

  • Comment on Re: Re: Golf Challenge - does $x and $y fit into the same slot on @z?
  • Download Code

Replies are listed 'Best First'.
Re^3: Golf Challenge - does $x and $y fit into the same slot on @z?
by Aristotle (Chancellor) on Dec 28, 2002 at 01:28 UTC
    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.

Re: Re: Re: Golf Challenge - does $x and $y fit into the same slot on @z?
by Anonymous Monk on Dec 28, 2002 at 21:27 UTC
    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