in reply to Re: screen out an untained array from a special array
in thread screen out an untained array from a special array
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...
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;
|
|---|
| 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 |