# Construct ASCII arches

I like ascii art and I get bored a lot, so I found some ascii characters and started to make random things, 8-bit mario castle, mazes, and arches. I found that the arches could easily be stacked in a neat way.

╔═══════╗
║╔═════╗║
║║╔═══╗║║
║║║╔═╗║║║
╨╨╨╨─╨╨╨╨


# Challenge

Create a program, function, or any other standard format that accepts an integer that is greater than or equal to 0 (unless you are doing the bonus) and outputs ascii art with the amount of arches specified.

# Test Cases

Input:

7


Output:

╔═════════════╗
║╔═══════════╗║
║║╔═════════╗║║
║║║╔═══════╗║║║
║║║║╔═════╗║║║║
║║║║║╔═══╗║║║║║
║║║║║║╔═╗║║║║║║
╨╨╨╨╨╨╨─╨╨╨╨╨╨╨


Alt:

+-------------+
|+-----------+|
||+---------+||
|||+-------+|||
||||+-----+||||
|||||+---+|||||
||||||+-+||||||
||||||| |||||||
---------------


Input:

1


Output:

╔═╗
╨─╨


Alt:

+-+
| |
---

• If the integer is 0 then don't output anything
• This question will be in utf-8, each character will count as a "byte"
• This is so the shortest answer wins.
• You have the option of using +-+ instead of ╔═╗, --- instead of ╨─╨, and | instead of ║

# Bonus (not decided whether to allow this on the alternate version because it wouldn't be as hard)

-10% if the program supports negative numbers and flips the arches like so

╥╥╥╥─╥╥╥╥
║║║╚═╝║║║
║║╚═══╝║║
║╚═════╝║
╚═══════╝

• AFAIK those are not ASCII characters. unicode-art – flawr Jan 10 '16 at 23:45
• welp, @flawr you are right. What now... – Hasan Jan 10 '16 at 23:48
• The world is going to collapse! Don't worry, perhaps just mention that they are not part of standard ASCII, but the ascii-art tag still applies (the unicode-tag was a joke.) – flawr Jan 10 '16 at 23:50
• That looks like extended ASCII, though, so you're probably okay. – Mama Fun Roll Jan 10 '16 at 23:51
• @ՊՓԼՃՐՊՃՈԲՍԼ There's no standard version of extended ASCII en.wikipedia.org/wiki/Extended_ASCII The closest thing there is is codepage 437 en.wikipedia.org/wiki/Code_page_437 which was standard in the USA and many other countries but I find when I copy and paste this into a codepage 437 editor and back into windows it "interprets" as arches with +---+ at the top, sides of | and a bottom of ----- which looks fine to me. Juanpotato, if you want to use non-ascii characters, please indicate the encoding in the question. As it stands I'm voting to close as unclear. – Level River St Jan 11 '16 at 0:13

# CJam, 59 bytes

qi:Lg"^Za"a{_0=1'Z3*tsa\{'[2*\*}%+}L(*'rL*a2*N*a+9462ff+N**


Try it here!

• You can now use +-| to build the arches, see op for examples. – Hasan Jan 11 '16 at 2:08

## 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.

• You can now use +-| to build the arches, see op for examples. – Hasan Jan 11 '16 at 2:05
• @JuanPotato OP stands for original poster. Do you mean the question? – Addison Crump Jan 11 '16 at 7:50
• @flagasspam yes, I've just seen uses where it means original post – Hasan Jan 11 '16 at 20:11

# 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

• I think this prints a single ─ for n = 0, but it should print nothing. – Lynn Jan 11 '16 at 1:41
• @Mauris I just ran it and you are correct – Hasan Jan 11 '16 at 2:08
• @Mauris Dang! You're absolutely right. My original version was fine, but somewhere along the line I lost the check. Fixed, at the cost of 4 chars. Thanks for spotting that. – type_outcast Jan 11 '16 at 5:59
• I know this is old, but to add to @Abigail's comment, you can save bytes using -n too: Try it online! – Dom Hastings Jul 11 '18 at 15:38

# Bash, 124 bytes (112 characters)

printf -vh %$1s b=${h// /╨}
h=${h// /═} for((n=$1;n--;)){
echo $v╔$h${h:1}╗$v
h=${h#?} v+=║ } (($1))&&echo $b─$b


Sample run:

bash-4.3$bash ascii-arch.sh 7 ╔═════════════╗ ║╔═══════════╗║ ║║╔═════════╗║║ ║║║╔═══════╗║║║ ║║║║╔═════╗║║║║ ║║║║║╔═══╗║║║║║ ║║║║║║╔═╗║║║║║║ ╨╨╨╨╨╨╨─╨╨╨╨╨╨╨ bash-4.3$ bash ascii-arch.sh 1
╔═╗
╨─╨

bash-4.3$bash ascii-arch.sh 0  # Japt-R, 29 bytes Uses + & -. Sacrificed 4 bytes to handle the bloody input validation! ©Æ'+²¬q-p´UÑÄÃpS û| p-pNÑÄ)ªP  Try it ## Explanation  :Implicit input of integer U © :Logical AND with U Æ :Map the range [0,U) '+ : Literal "+" ² : Repeat twice ¬ : Split q : Join with - : Literal "-" p : Repeat ´U : Decrement U Ñ : Multiply by 2 Ä : Add 1 Ã :End mapping pS :Push a space û| :Centre pad each element with "|" to the length of the longest element p ) :Push - : Literal "-" p : Repeat N : The array of inputs (which will be cast to an integer if we perform a mathematical operation on it) ÑÄ : Multiply by 2 and add 1 ª :Logical OR P :The empty string :Implicitly join with newlines and output  • fails on the input 0 – dzaima Jul 11 '18 at 10:06 • @dzaima, what do you mean? How can you have an arch of size 0? – Shaggy Jul 11 '18 at 10:15 • If the integer is 0 then don't output anything from the challenge :/ – dzaima Jul 11 '18 at 10:16 • @dzaima, Oh, I missed that. Thanks. First of all: Boo-urns to input validation! Secondly, Japt can't output nothing - I could output 0, false or an empty string at a cost of some bytes but I don't know if any of those would be acceptable except, maybe, the empty string, which would cost me 5 bytes (0 would only cost me 1). – Shaggy Jul 11 '18 at 10:19 # JavaScript (ES6), 101 characters f=(n,i=0)=>n?i-n?(b="║"[r="repeat"](i))+╔${"═"[r]((n-i)*2-1)}╗${b} +f(n,i+1):(g="╨"[r](n))+"─"+g:""  ## Explanation Recursive function that prints each line f=(n,i=0)=> // f = recursive function, i = current line (default = 0) n? // if n != 0 i-n? // if we are not in the last line, print the line (b="║"[r="repeat"](i))+╔${"═"[r]((n-i)*2-1)}╗${b} +f(n,i+1) // add the output of the next line :(g="╨"[r](n))+"─"+g // if we ARE in the last line, print the last line :"" // print nothing if n = 0  ## Test Test does not use default parameter for browser compatibility. var solution = f=(n,i)=>n?(i|=0)-n?(b="║"[r="repeat"](i))+╔${"═"[r]((n-i)*2-1)}╗${b} +f(n,i+1):(g="╨"[r](n))+"─"+g:"" <input type="number" oninput="result.textContent=solution(+this.value)" /> <pre id="result"></pre> # PHP (109 chars) $s='';for($b=($n=$argv[1])?'─':'';$n--;){echo$s.'╔═'.str_repeat('══',$n)."╗$s\n";$s.='║';$b="╨{$b}╨";}echo$b;  Still need to get rid of that str_repeat but most alternatives won't handle mulyibyte chars. $s = '';
// Initialise $b (bottom) to '─' or '' for n==0 for ($b = ($n =$argv[1]) ? '─' : ''; $n--;) { // Echo sides + arch + sides echo$s . '╔═' . str_repeat('══', $n) . "╗$s\n";
// Growing sides
$s .= '║'; // Growing bottom$b = "╨{$b}╨"; } // Show bottom echo$b;


# Retina, 79 chars

.+
$0$*═$0$*═╗
^═
╔
+(║*)╔═(═+)═╗║*0¶$1║╔$2╗║$1 (\S+)$
$0¶$1
T═╔╗║─╨\S+$ Try it online. This uses a new feature in Retina that replaces a decimal number \d+ with a list of that many characters $0$*═. # Swift (209 bytes) Probably Swift is not the best language for this, this is my first time trying to do a code golf challenge: func *(l:String,r: Int)->String{return r>0 ?l+(l*(r-1)):""} let n=Int(readLine()!)! for i in 0...(n-1){let a=("║"*i)+"╔═";let b=a+("══"*(n-1-i))+"╗"+("║"*i);print(b)};print("╨"*n+"─"+"╨"*n)  # Ruby, 90 bytes (74 characters) ->n{n.times{|i|puts ?║*i+?╔+?═*((n-i)*2-1)+?╗+?║*i}>0&&puts(?╨*n+?─+?╨*n)}  Sample run: 2.1.5 :001 > ->n{n.times{|i|puts ?║*i+?╔+?═*((n-i)*2-1)+?╗+?║*i}>0&&puts(?╨*n+?─+?╨*n)}[7] ╔═════════════╗ ║╔═══════════╗║ ║║╔═════════╗║║ ║║║╔═══════╗║║║ ║║║║╔═════╗║║║║ ║║║║║╔═══╗║║║║║ ║║║║║║╔═╗║║║║║║ ╨╨╨╨╨╨╨─╨╨╨╨╨╨╨ => nil 2.1.5 :002 > ->n{n.times{|i|puts ?║*i+?╔+?═*((n-i)*2-1)+?╗+?║*i}>0&&puts(?╨*n+?─+?╨*n)}[1] ╔═╗ ╨─╨ => nil 2.1.5 :003 > ->n{n.times{|i|puts ?║*i+?╔+?═*((n-i)*2-1)+?╗+?║*i}>0&&puts(?╨*n+?─+?╨*n)}[0] => false  # Haskell, 151 162 bytes r=replicate c=concat f n=putStr$unlines[c[r i '║',"╔",r(2*(n-i)-1)'═',"╗",r i '║']|i<-[0..n-1]]++c[r n '╨',r(signum n)'─',r n '╨']


Edit: I forgot to deal with 0 as input

⩥ïⓜᵖ⟮ ⍘|ď⟯$++⦃⟮⍘-ď (ï⟯-$)*2-1)}++Ⅰ$;ï⅋ᵖⅠï+⬭+Ⅰï,Ⅱ*2+1  Try it here (Firefox only). # Explanation ⩥ïⓜᵖ⟮ ⍘|ď⟯$++⦃⟮⍘-ď (ï⟯-$)*2-1)}++Ⅰ$;ï⅋ᵖⅠï+⬭+Ⅰï,Ⅱ*2+1 // implicit: ï=input, $=mapped item // PHASE 1 ⩥ïⓜ // create a range to map over ᵖ // push to stack: ⟮ ⍘|ď⟯$                                            // | repeated $times ++⦃⟮⍘-ď (ï⟯-$)*2-1)}+                      // & +[- repeated 2$-1 times]+ +Ⅰ$;                  // & | repeated $times // PHASE 2 ï⅋ // if ï>0 ᵖ // push to stack 2 items: Ⅰï+⬭+Ⅰï, // | repeated$ times & [space] & | repeated $times Ⅱ*2+1 // and - repeated 2ï+1 // implicit stack output, newline-separated  NOTE: this makes use of good ol' copy blocks to get at the spots where ordinary variable declaring could not reach. # Sed, 97 bytes (81 characters) (96 bytes (80 characters) code + 1 character command line option) s/.(.*)/2&\13/ t : H s/(.+)11(.+)/4\1\24/ t y/1234/─╨╨╨/ H g s/\n// y/1234/═╔╗║/  Input expected as unary integer. Sample run: bash-4.3$ sed -r 's/.(.*)/2&\13/;t;:;H;s/(.+)11(.+)/4\1\24/;t;y/1234/─╨╨╨/;H;g;s/\n//;y/1234/═╔╗║/' <<< '1111111'
╔═════════════╗
║╔═══════════╗║
║║╔═════════╗║║
║║║╔═══════╗║║║
║║║║╔═════╗║║║║
║║║║║╔═══╗║║║║║
║║║║║║╔═╗║║║║║║
╨╨╨╨╨╨╨─╨╨╨╨╨╨╨

bash-4.3$sed -r 's/.(.*)/2&\13/;t;:;H;s/(.+)11(.+)/4\1\24/;t;y/1234/─╨╨╨/;H;g;s/\n//;y/1234/═╔╗║/' <<< '1' ╔═╗ ╨─╨ bash-4.3$ sed -r 's/.(.*)/2&\13/;t;:;H;s/(.+)11(.+)/4\1\24/;t;y/1234/─╨╨╨/;H;g;s/\n//;y/1234/═╔╗║/' <<< ''


# Sed, 105 bytes (75 characters)

(104 bytes (74 characters) code + 1 character command line option)

y/1/═/
s/.(.*)/╔&\1╗/
t
:
H
s/(.+)══(.+)/║\1\2║/
t
y/╔║╗═/╨╨╨─/
H
g
s/\n//


Input expected as unary integer.

Sample run:

bash-4.3$sed -r 'y/1/═/;s/.(.*)/╔&\1╗/;t;:;H;s/(.+)══(.+)/║\1\2║/;t;y/╔║╗═/╨╨╨─/;H;g;s/\n//' <<< '1111111' ╔═════════════╗ ║╔═══════════╗║ ║║╔═════════╗║║ ║║║╔═══════╗║║║ ║║║║╔═════╗║║║║ ║║║║║╔═══╗║║║║║ ║║║║║║╔═╗║║║║║║ ╨╨╨╨╨╨╨─╨╨╨╨╨╨╨ bash-4.3$ sed -r 'y/1/═/;s/.(.*)/╔&\1╗/;t;:;H;s/(.+)══(.+)/║\1\2║/;t;y/╔║╗═/╨╨╨─/;H;g;s/\n//' <<< '1'
╔═╗
╨─╨

bash-4.3\$ sed -r 'y/1/═/;s/.(.*)/╔&\1╗/;t;:;H;s/(.+)══(.+)/║\1\2║/;t;y/╔║╗═/╨╨╨─/;H;g;s/\n//' <<< ''


# Canvas, 15 bytes

-＊+∔］⤢：↷±ｎ│Ｌ-×∔


Try it here!

Explanation:

{    ]            map over 1..input
-*                 repeat "-" counter times
+∔               append "+" to that
⤢           transpose
:          create a duplicate of that
↷±        rotated 90°, then reversed horizontally
n       overlap the 2
|      and palindromize horizontally with 1 overlap
L     get the with of that
-×   repear "-" that many times
∔  and add vertically to the rest of the output