Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Remove the duplication in Hash values

by SimonClinch (Chaplain)
on May 20, 2011 at 08:18 UTC ( #905879=note: print w/ replies, xml ) Need Help??


in reply to Remove the duplication in Hash values

If I understand correctly, you can't! Or at least, the array locations 0 and 0 thru 10 in the respective arrays in the output hash will have been autovivified giving existing addresses (test with exists()) populated however with undef(), although those above the upper limit you defined will not have come into existence.

Update: You probably want just arrays (ie reconsider the storage model) of [0..9] and to iterate them afresh for each key iteration of the containing hash when reading and writing to the hash.

Oops a cow flew by. Therefore a corrected response: There need to be clearer rules for the deletion - must the solution be contiguous? ie must it allow gaps if there is no other way to include a set that doesn't overlap another - what if two ranges overlap but are of the same size with one higher than the other - how is a winner selected between them?

One world, one people


Comment on Re: Remove the duplication in Hash values
Download Code
Re^2: Remove the duplication in Hash values
by lidden (Deacon) on May 20, 2011 at 10:54 UTC
    No, the [1..10] in %input=(r=>[1..10],s=>[1..10] is an array reference with values 1 to 10, which is possible. You cannot have an array without index zero, but nothing in the OP says he wants to do that.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-10-23 10:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls