in reply to Re: screen out an untained array from a special array
in thread screen out an untained array from a special array

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 :-))

Replies are listed 'Best First'.
Re^3: screen out an untained array from a special array
by Lawliet (Curate) on Feb 08, 2009 at 02:32 UTC

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

    And you didn't even know bears could type.