That's such tightly constrained input that only the first value of a row is needed to check it.
The usual hash for checking uniqueness is unneeded here because of the additional arithmetic properties you want.sub are_consecutive { my $i = $_[0]; $_ == $i++ or return 0 for @_; 1; } are_consecutive(@{$_}) or die "User can't count.$/" for values %hsh; my @big = sort {$a <=> $b} map {@{$_}} values %hsh; $big[0] == 0 && are_consecutive(@big) or die "Bad big.$/"; # originally had soln in terms of $big[0] == 0 and $big[-1] == $#big # rejected because equal number of missing and doubled terms not detec +ted
What application requires that a user partition 0..N this way?
Update: cleaned up and corrected for offsetting double errors
After Compline,
Zaxo
In reply to Re: joining and sorting arrays
by Zaxo
in thread joining and sorting arrays
by hotshot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |