Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,38 @@
sub cubLine ($$$$) {
my ($n, $dx, $dy, $cde) = @_;
printf '%*s', $n + 1, substr($cde, 0, 1);
for (my $d = 9 * $dx - 1 ; $d > 0 ; --$d) {
print substr($cde, 1, 1);
}
print substr($cde, 0, 1);
printf "%*s\n", $dy + 1, substr($cde, 2, 1);
}
sub cuboid ($$$) {
my ($dx, $dy, $dz) = @_;
printf "cuboid %d %d %d:\n", $dx, $dy, $dz;
cubLine $dy + 1, $dx, 0, '+-';
for (my $i = 1 ; $i <= $dy ; ++$i) {
cubLine $dy - $i + 1, $dx, $i - 1, '/ |';
}
cubLine 0, $dx, $dy, '+-|';
for (my $i = 4 * $dz - $dy - 2 ; $i > 0 ; --$i) {
cubLine 0, $dx, $dy, '| |';
}
cubLine 0, $dx, $dy, '| +';
for (my $i = 1 ; $i <= $dy ; ++$i) {
cubLine 0, $dx, $dy - $i, '| /';
}
cubLine 0, $dx, 0, "+-\n";
}
cuboid 2, 3, 4;
cuboid 1, 1, 1;
cuboid 6, 2, 1;

View file

@ -0,0 +1,27 @@
use 5.010;
# usage: script X Y Z [S]
sub cuboid {
# Constant dimnesions of the cuboid
my ($x, $y, $z) = map int, @_[0 .. 2];
# ASCII characters
# $c = corner point
# $h = horizontal line
# $v = vertical line
# $d = diagonal line
# $s = space (inside the cuboid)
my ($c, $h, $v, $d, $s) = ('+', '-', '|', '/', shift(@ARGV) // q{ });
say q{ } x ($z + 1), $c, $h x $x, $c;
say q{ } x ($z - $_ + 1), $d, $s x $x, $d, $s x ($_ - ($_ > $y ? ($_ - $y) : 1)),
$_ - 1 == $y ? $c : $_ > $y ? $d : $v for 1 .. $z;
say $c, $h x $x, $c, ($s x ($z < $y ? $z : $y), $z < $y ? $v : $z == $y ? $c : $d);
say $v, $s x $x, $v, $z > $y ? $_ >= $z ? ($s x $x, $c) : ($s x ($y - $_), $d)
: $y - $_ > $z ? ($s x $z, $v) : ($s x ($y - $_), $y - $_ == $z ? $c : $d) for 1 .. $y;
say $c, $h x $x, $c;
}
cuboid shift // rand 20, shift // rand 10, shift // rand 10;