Aufgabenstellung ist, folgenden Perl Code in php umzuschreiben:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use warnings;
use strict;
my @data = qw(
# ...
);
my @new;
my @data_tmp = @data;
while (1) {
my %test;
@new = ();
for my $item (@data_tmp) {
next if $item !~ /^\d{2,}$/;
my $suffix = chop($item);
$test{$item}{$suffix}++;
}
for my $base (keys %test) {
if (scalar(keys %{$test{$base}}) == 10) {
push @new, $base;
}
else {
push @new, $base.$_ for keys %{$test{$base}};
}
}
last if $#new == $#data_tmp;
@data_tmp = @new;
}
print "$_\n" for sort @new;
Last edited: 2013-03-04 13:41:19 +0100 (CET)