Skip to main content
Commonmark migration
Source Link

#Perl, 184 bytes $n=pop;$p=$n>0;$=' \ /'x(1+abs$n3);$n=$p?$n4+1:3;$=join' ',/.{$n}/g;$r=$p?'.':'.* ';s/($r$r)$r($r)/$1$2/g;$p and s/^\S|\S$/O/gm or s/^ \S $|(?<=^ )\S|\S $/O/g;y~\/~/\~if$p;print;

Perl, 184 bytes

$n=pop;$p=$n>0;$_=' \ /'x(1+abs$n*3);$n=$p?$n*4+1:3;$_=join' ',/.{$n}/g;$r=$p?'.':'.* ';s/($r$r)$r($r)/$1$2/g;$p and s/^\S|\S$/O/gm or s/^ \S $|(?<=^ )\S|\S $/O/g;y~\\/~/\\~if$p;print; 

I thought this was going to be a lot shorter! There are probably some simple things I can do to save a few bytes. It's been five years since I've programmed seriously in Perl!

#Perl, 184 bytes $n=pop;$p=$n>0;$=' \ /'x(1+abs$n3);$n=$p?$n4+1:3;$=join' ',/.{$n}/g;$r=$p?'.':'.* ';s/($r$r)$r($r)/$1$2/g;$p and s/^\S|\S$/O/gm or s/^ \S $|(?<=^ )\S|\S $/O/g;y~\/~/\~if$p;print;

I thought this was going to be a lot shorter! There are probably some simple things I can do to save a few bytes. It's been five years since I've programmed seriously in Perl!

Perl, 184 bytes

$n=pop;$p=$n>0;$_=' \ /'x(1+abs$n*3);$n=$p?$n*4+1:3;$_=join' ',/.{$n}/g;$r=$p?'.':'.* ';s/($r$r)$r($r)/$1$2/g;$p and s/^\S|\S$/O/gm or s/^ \S $|(?<=^ )\S|\S $/O/g;y~\\/~/\\~if$p;print; 

I thought this was going to be a lot shorter! There are probably some simple things I can do to save a few bytes. It's been five years since I've programmed seriously in Perl!

Source Link
CJ Dennis
  • 4.3k
  • 1
  • 18
  • 34

#Perl, 184 bytes $n=pop;$p=$n>0;$=' \ /'x(1+abs$n3);$n=$p?$n4+1:3;$=join' ',/.{$n}/g;$r=$p?'.':'.* ';s/($r$r)$r($r)/$1$2/g;$p and s/^\S|\S$/O/gm or s/^ \S $|(?<=^ )\S|\S $/O/g;y~\/~/\~if$p;print;

I thought this was going to be a lot shorter! There are probably some simple things I can do to save a few bytes. It's been five years since I've programmed seriously in Perl!