Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
30
use strict; use Test::More q(no_plan); my @z = qw(1 3 27 38); my $x = shift(); my $y = shift(); my @test = ( [qw( 4 5) => 1], [qw( 0 -1) => 1], [qw(100 100) => 1], [qw( 10 27) => 1], [qw( 3 27) => 0], [qw( 0 100) => 0], ); sub bool { not not shift } for(@test) { my ($x, $y, $works) = @$_; is( # 1 2 3 #23456789012345678901234567890 ((grep$x<=$_,@z)==grep$y<=$_,@z), bool($works), "x=$x y=$y" ); } __END__ ok 1 - x=4 y=5 ok 2 - x=0 y=-1 ok 3 - x=100 y=100 ok 4 - x=10 y=27 ok 5 - x=3 y=27 ok 6 - x=0 y=100 1..6

Makeshifts last the longest.


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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-18 18:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found