Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
grid
#perl 5.26.1 my $side=5; my @grid=([ ([ (0)x$side])x$side])x$side; print $grid[1][2][3]; sub getAllInLine{ my $position =shift; my @inLine=(); my @unoccupied=(); foreach my $deltaX(-1..1){ foreach my $deltaY(-1..1){ foreach my $deltaZ(-1..1){ next unless $deltaX or $deltaY or $deltaZ; foreach my $distance (1..$side-1){ my $test={x=>$$position{x}+$distance*$deltaX, y=>$$position{y}+$distance*$deltaY, z=>$$position{z}+$distance*$deltaZ}; last if outOfBouds($test); push @inLine,$test; push @unoccupied,$test unless $gridContent($test) } } } } } sub gridContent{ my $position =shift; } sub outOfBounds{ my $position =shift; return 1 if $$position{x} < 0 or $$position{y} < 0 or $$position{z} < 0 or $$position{x} >= $side or $$position{y} >= $side or $$position{z} >= $side; return 0; }
run
|
edit
|
history
|
help
0
Perl
taller in front
Simple Perl Interview Question
Perl
Supriya
main_objetos
Challenge 41 Task 1
OSTL
base N conversion
Hash