Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

Re: Perl Weekly Challenge 206 -- oneliner

by Discipulus (Canon)
on Mar 20, 2023 at 08:56 UTC ( [id://11151078] : note . print w/replies, xml ) Need Help??

in reply to Perl Weekly Challenge 206 with List::Util always for my own fun, the second task is easy using a hash with expected values as keys and values incremented for expected args $ARGV[0]..$ARGV[-1] and for actual args @ARGV so a key with a value of 1 is a missing number and a key with a value of 3 is a duplicate. If nothing of this happens return -1

perl -E "map{$h{$_}++}$ARGV[0]..$ARGV[-1],@ARGV;map{$h{$_}==3?$r.=' Du +plicate is '.$_:$h{$_}==1?$r.=' Missing is '.$_:''}keys%h;say $r||-1"


UPDATE ..oops! yes LanX is right I jumped to 208, sorry.

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Perl Weekly Challenge 206 -- oneliner
by LanX (Saint) on Mar 20, 2023 at 11:13 UTC
    that's an answer to challenge 206 task 2 ?

    I provided a test-suite in my OP, not sure how best to generalize it to fit for one-liner too. (probably by shelling out?)


    did you skip to 208?

    Cheers Rolf
    (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
    Wikisyntax for the Monastery