Construct ASCII arches
Python 2, 106 bytes (94 chars)
n=input();j=1
exec"s=j/2*'║';print s+'╔'+'═'*(2*n-j)+'╗'+s;j+=2;"*n
if n:t='╨'*n;print t+'─'+t
Pretty straightforward. Prints line by line with a changing number of horizontal and vertical bars. The last line is printed separately.
I feel like I'm missing some optimizations. The fact that the chars are multiple bytes means you can't do something like '║╨'[n>0]
, so I didn't find a good way to print the last line in the loop. It's ugly that there's so much manipulation going on with the counter. I'd like update strings directly, like s+='║'
, but the index is also used for horizontal bars.
Perl, 78 82 chars
$n='─';$_='══'x pop;while(s/══//){print"$s╔═$_╗$s\n";$s.="║";$n="╨$n╨"}$s&&print$n
Sadly, I couldn't figure out a way to take advantage of the bonus without increasing the size by more than 10%. I may yet prevail.
Ungolfed
Pretty straightforward, really. Builds up bottom line (╨$n╨
) incrementally, while shortening top line (══
) by two characters, ending when it can no longer be shortened, so I don't have to mess with counters.
$n = '─'; # Bottom line
$_ = '══'x pop; # "Top" line, length from commandline argument
while (s/══//) { # Shorten top line by two characters
print "$s╔═$_╗$s\n"; # Print current line with $s (sides)
$s .= "║"; # Append vertical bar to sides
$n = "╨$n╨"; # Widen bottom line
}
$s && print $n; # Print bottom line if input is not 0