Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by BrowserUk (Patriarch)
on Dec 28, 2002 at 00:38 UTC ( [id://222655]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://222655]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-20 01:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found