in reply to Re^2: Find duplicate digits
in thread Find duplicate digits
my @keep; # numbers to keep while(chomp( my $line = <NUMBERS> ) ) { my %count; ++$count{$_} for split '', $line; push @keep, $line if grep { $_ == 2 } values %count }
I also wouldn't be surprised if the regex method was slower, but I'm too lazy to do a benchmark right now. :) (And for only 10,000 numbers, it probably does not matter much.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Find duplicate digits
by radiantmatrix (Parson) on Feb 15, 2006 at 18:46 UTC | |
by GrandFather (Saint) on Feb 16, 2006 at 03:51 UTC |