#!/usr/bin/perl
use 5.016;
use warnings;
sub new {
}
sub value { $_[0]->[0] }
sub next { ref $_[0]->[1] eq 'CODE' ? $_[0]->[1] = $_[0]->[1]->() : $_[0]->[1] }
my @dir = ([1, 0], [0, 1], [-1, 0], [0, -1]);
sub f1 {
my ($x, $y, $l, $c, $d) = @_;
my ($dx, $dy) = @{$dir[$d]};
[$x, $y],
(($c < 1) ?
sub{ f2($x + $dx, $y + $dy, $l + 1, $l + 1, ($d + 1) % 4) } :
sub{ f1($x + $dx, $y + $dy, $l, $c - 1, $d) }
)
);
}
sub f2 {
my ($x, $y, $l, $c, $d) = @_;
my ($dx, $dy) = @{$dir[$d]};
[$x, $y],
(($c < 1) ?
sub{ f1($x + $dx, $y + $dy, $l, $l, ($d + 1) % 4) } :
sub{ f2($x + $dx, $y + $dy, $l, $c - 1, $d) }
)
);
}
sub f { f2(0, 0, 0, 0, 0) }
sub is_prime {
my ($n) = @_;
for(my $i = 3; $i <= $n / $i; $i += 2){
}
}
sub g {
my $n = ($o * 2 + 1) ** 2;
my @d;
my $f = f();
foreach(1 .. $n){
my ($x, $y) = @{$f->value};
$f = $f->next;
$d[$o - $y]->[$o + $x] = (is_prime($_) ? '*' : ' ');
}
}
foreach(g(79)){
say @{$_};
}
IyEvdXNyL2Jpbi9wZXJsCnVzZSA1LjAxNjsKdXNlIHdhcm5pbmdzOwoKcGFja2FnZSBfU3RyZWFtOwoKc3ViIG5ldyB7CglteSAkY2xhc3MgPSBzaGlmdDsKCXJldHVybiBibGVzcyBbIEBfIF0sICRjbGFzczsKfQoKc3ViIHZhbHVlIHsgJF9bMF0tPlswXSB9CnN1YiBuZXh0IHsgcmVmICRfWzBdLT5bMV0gZXEgJ0NPREUnID8gJF9bMF0tPlsxXSA9ICRfWzBdLT5bMV0tPigpIDogJF9bMF0tPlsxXSB9CgpwYWNrYWdlIG1haW47CgpteSBAZGlyID0gKFsxLCAwXSwgWzAsIDFdLCBbLTEsIDBdLCBbMCwgLTFdKTsKCnN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