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

Re: Sorting challenge

by tobyink (Abbot)
on Jul 22, 2013 at 21:27 UTC ( #1045729=note: print w/replies, xml ) Need Help??

in reply to Sorting challenge

This condition never happens:

last if ($_ eq '');

So your while loop just keeps going and going. Their test harness is expecting you to return a sorted list of numbers, but your script is just sitting there waiting for more input.

Your input loop should be something like:

chomp(my $count = <>); my @numbers; for (1 .. $count) { chomp(my $line = <>); die if $line < 1 || $line > 1_000_000; push @numbers, $line; }
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Replies are listed 'Best First'.
Re^2: Sorting challenge
by PerlSufi (Friar) on Jul 22, 2013 at 21:35 UTC
    Great, thanks tobyink. I'll give that a try

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1045729]
[Lady_Aleena]: Renaming things like get_THAC0 to just THAC0 was easy. These are harder.
[james28909]: consolidate the three subs into one
[Lady_Aleena]: Um, what?
[james28909]: check is is data or hash or array and do tasks then return needed data
[Lady_Aleena]: james28909, you might want to look at the other two on my scratchpad.
[james28909]: after you send to a sub, you can check if it is array or ref ect with ref
[james28909]: check if it is a hash or an array ect with ref in one sub.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2017-05-24 04:52 GMT
Find Nodes?
    Voting Booth?