#!/usr/bin/perl use strict; use warnings; # spielfeld my @aa=( [qw /28 22 15 6 33 1/], [qw / 7 10 32 27 11 14/], [qw /23 18 5 31 9 30/], [qw / 4 36 29 20 16 24/], [qw /13 25 17 3 35 19/], [qw /34 2 26 12 21 8/], ); #*********************************** Programm *************** sub stepp_trou { my $matrix=shift; my $sx=shift; my $sy=shift; my $size=shift; for my $y (0..$#$matrix) { for my $x (0..$#{$matrix->[$y]}) { my @list=(); my ($rx,$ry)=($x,$y); # Reihe suchen while($ry<@$matrix && $rx<@{$matrix->[$y]}) { push(@list,$matrix->[$ry]->[$rx]); $rx+=$sx; $ry+=$sy; last if(@list==$size); } # Reihe gefunden if(@list==$size) { print join("\t",@list)."\n"; next(); } # Nur bei Diagonalen auch rückwärts suchen next unless($sx && $sy); @list=(); ($rx,$ry)=($x,$y); # Reihe suchen while($ry>=0 && $rx<@{$matrix->[$y]}) { push(@list,$matrix->[$ry]->[$rx]); $rx+=$sx; $ry-=$sy; last if(@list==$size); } # Reihe gefunden print join("\t",@list)."\n" if(@list==$size); } #print "\n"; } } print "\n*** Die Diagonalen ***\n"; stepp_trou(\@aa,1,1,4); print "\n*** Die Senkrechten ***\n"; stepp_trou(\@aa,0,1,4); print "\n*** Die Waagerechten ***\n"; stepp_trou(\@aa,1,0,4);