Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Difference arrays.

by betterworld (Curate)
on Sep 04, 2008 at 19:30 UTC ( [id://709104]=note: print w/replies, xml ) Need Help??


in reply to Difference arrays.

my @p = (1,1,1,1,1,2,2,2,3,3,4,5,6); my @q = (1,2,3,4,5,6 ); # my @p = (43, 43, 44); # my @q = (43, 43); my %q; $q{$_}++ for @q; my @r = grep { --$q{$_} < 0; } @p; print join (',', @r), "\n";

Replies are listed 'Best First'.
Re^2: Difference arrays.
by BrowserUk (Patriarch) on Sep 04, 2008 at 20:30 UTC
Re^2: Difference arrays.
by Skeeve (Parson) on Sep 04, 2008 at 19:36 UTC

    Similar idea like mine above , but much, much better than I did it! ++ and ++ could I vote twice!


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Re^2: Difference arrays.
by journey (Monk) on Sep 06, 2008 at 02:34 UTC
Re^2: Difference arrays.
by Skeeve (Parson) on Sep 04, 2008 at 21:27 UTC

    Big bug

    Just found it when I was examining kyle's solution.

    swap p and q and your routine will fail!

    Sorry! Not a bug! My mistake!


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

      I noticed that your solution is symmetric because it has the abs in it. However I was taking BrowserUk by the word: "those in the first not in the second".

      Given the restriction "one a proper subset of the other", it does not matter, and our solutions print essentially the same elements (maybe in a different order).

        Something I learned again: Keep your big mouth shut until you read a second time ;-) So Sorry for crying too early. MINE has the bug. I've added comments above.


        s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
        +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2026-01-15 20:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (118 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.