in reply to screen out an untained array from a special array

Say I got a array ranging from 0 to 31 eg. 0, 6:2, 17:8 and 9:31 where digit means digit, (\d+):(\d+) means $2..$1 (or $1..$2 if $2>$1);
I want know which number is NOT listed in the array within 31:0.

input array : 0, 6:4, 12:8 and 19:31 (means: 0, 4, 5, 6, 8, .. 17, 19, 20 .. 31)
expected output: 3:1, 7, 13:18 (means: 1, 2, 3, 7, 13, 14 .. 17, 18)

What?

I am not in the mood to decipher that. Please read How (Not) To Ask A Question and then explain your question again.

And you didn't even know bears could type.

  • Comment on Re: screen out an untained array from a special array

Replies are listed 'Best First'.
Re^2: screen out an untained array from a special array
by Bloodnok (Vicar) on Feb 08, 2009 at 02:20 UTC
    IMO How (Not) To Ask A Question won't be able to help Hanken as much as you would like it to, self-evidently (and from browsing his home node), English isn't ever going to be the strong point - but we shouldn't hold that against them.

    I admit I've read easier stuff, but I (think I) got there after not too long ...

    IMO, the OP has, as its basis, an array of integers (each in the range 0 .. 31) - where sequences of consecutive numbers e.g. 2,3,4,5,6 can be shortened using a colon ':' e.g. 2:6 (but not necessarily in ascending order). The problem laid out in the OP can be summarised as the solving of the following 2 problems...

    1. expand the/any ranges (colon connected digit sequences) in the list.
    2. determine (and lists), numbers in the same range i.e. 0 .. 31, that are missing from i.e. don't appear in, the array (containing range expansions).

    Update:

    use warnings; use strict; my @data = qw/0 6:4 12:8 19:31/; my %nums = map { ( $_ => undef ) } 0 .. 31; map { local @_ = sort { $a <=> $b } split /:/; for (my $n = $_[0]; $n < ( @_ == 1 ? $_[0] + 1 : $_[1] + 1 ); $n++ + ) { delete $nums{$n}; } } @data; print "$_\n" foreach sort keys %nums;

    A user level that continues to overstate my experience :-))

      Yes, I figured out what he meant once he reworded the OP.

      And you didn't even know bears could type.

Re^2: screen out an untained array from a special array
by Hanken (Acolyte) on Feb 08, 2009 at 01:41 UTC
    Sorry... I need to find a way to explain it.