# The Letter E with E

Your task is to display the below letter "E" shaped ASCII art, given five inputs.

Examples:

Input: 7,2,+,|,- (Note: You don't have to follow this exact input format, and if you don't use it, then you must explain how your own input format works)

Explanation:

• 7 total width, including the left and right edge characters.

• 2 Number of vertical characters.

• + The character that should display at the edges.

• | The character that should display vertically between the edges.

• - The character that should display horizontally.

Output of the above example:

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


Other examples:

Input: 7,2,@,|,-

Output:

@-----@
|
|
@-----@
|
|
@-----@


Input: 7,2,+,|,#

Output:

+#####+
|
|
+#####+
|
|
+#####+


Input: 8,3,+,|,#

Output:

+######+
|
|
|
+######+
|
|
|
+######+


Input: 8,3,+,@,#

Output:

+######+
@
@
@
+######+
@
@
@
+######+


Input: 9,4,^,$,! Output: ^!!!!!!!^$

$^!!!!!!!^$

^!!!!!!!^  Cheating and standard loopholes are not allowed. Your code must not print anything to STDERR. Your code may accept any character encoding you choose as the input, but any character encoding you choose must, as a minimum, support all the 95 printable ASCII characters. The shortest code, in bytes, that completes this challenge successfully, is the winning code. ### Leaderboard var QUESTION_ID=92138,OVERRIDE_USER=58717;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i; body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px} <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> • I dislike the special case of 'no input given'. In my opinion, it doesn't add anything to the challenge and complicates a lot for nothing. – Yytsi Sep 3 '16 at 16:43 • Is the title because you could give E as an input, and make an E with Es? – trichoplax Sep 3 '16 at 16:56 • Despite that I dislike it, what does the 'no input' really mean? My Floroid solution will just hang for the rest of eternity if you don't pass input. For my solution to be competing, you'd have to pass 5 zeroes and I would have to check whether the inputs are zeroes and treat accordingly...? -1. – Yytsi Sep 3 '16 at 17:17 • @TheBitByte See my second comment to see what I think is really wrong with it. Now that you edited that out, +1. – Yytsi Sep 3 '16 at 17:49 • @Kevin Yup. I was just having a little confusion with interpretation of 'no input'. Empty string is not equal to 'no input' in my mind. And I was so used to run the code inside an interpreter, on which I literally wait for the input to be fed, so that's why I threw that out there. – Yytsi Sep 4 '16 at 6:08 ## 27 Answers # 05AB1E, 16 14 bytes Í×s.ø©|×»D®»  Explanation Í× # create a string of the correct nr of horizontal chars s.ø # add the corner char on both sides © # save in register while keeping it on the stack | # push the remaining inputs to the top of the stack × # push the correct nr of vertical chars on the stack » # join on newline (joining the top vertical and horizontal sections) D # duplicate this ® # push the horizontal part again » # join everything on newline  Try it online! Saved 4 bytes thanks to Adnan. • Out of curiosity, why are you using the © register :p? – Adnan Sep 3 '16 at 17:42 • @Adnan: Good catch! I was going to, but ended up not using it and forgot to remove it :) – Emigna Sep 3 '16 at 17:46 • @muddyfish: Reading the explanation from the question that part wasn't obvious, so I missed it. Thanks for letting me know! – Emigna Sep 3 '16 at 20:14 • There's also a special surround command which works here: Í×s.øU×S»X»D»Xr». – Adnan Sep 3 '16 at 20:42 • @Adnan: Right you are. Good thinking! I've never used that before :) – Emigna Sep 3 '16 at 20:47 # Python, 5351 55 Bytes lambda a,b,c,d,e:d.join("\n"*-~b).join([c+e*(a-2)+c]*3)  +4 Bytes thanks to @nimi anonymous lambda function, to call it, write f= before it. Example: >>> print f(4,1,"€","|","-") €--€ | €--€ | €--€  ## alternative, 53 Bytes lambda a,b,c,d,e:((c+e*a+c+"\n"+(d+"\n")*b)*3)[:-b*2]  ## old version with the special case of no input, 6965 63 Bytes yay to changing the requirements mid-challenge... lambda a=1,b=1,(c,d,e)="+|-":d.join("\n"*-~b).join([c+e*a+c]*3)  • Small bug: the first argument (2 in your example) is the total length of the line, including the corners, so the right input for your shape is f(4,1 ...). – nimi Sep 3 '16 at 18:57 • @nimi thanks for the tip. (+4 bytes :( ) OPs first example is a bit confusing. (Some of the other answers have this bug aswell) – KarlKastor Sep 3 '16 at 22:06 # C, 167161 159 bytes Yeah. #define p putchar i,j;g(a,c,e){p(c);for(i=2;i++<a;)p(e);p(c);p(10);}h(b,d){for(i=0;i++<b;){p(d);p(10);}}f(a,b,c,d,e){g(a,c,e);h(b,d);g(a,c,e);h(b,d);g(a,c,e);}  Try it on Ideone, with some test cases • puts("") -> p('\n') ? or even p(10) if that'll work – RiaD Sep 4 '16 at 22:03 • How did I miss that! Thanks, @RiaD. – betseg Sep 4 '16 at 23:34 • Also if you start loop with 2, you will save to more bytes – RiaD Sep 5 '16 at 6:51 # Ruby, 5445 42 bytes ->x,y,c,v,h{[c+h*~-~-x+c+/]*3*((v+$/)*y)}  It's an anonymous function that takes the different part of the input as separate parameters and returns the result as a complete string. For example, f=->x,y,c,v,h{[c+h*~-~-x+c+$/]*3*((v+$/)*y)} puts f[6, 2, 'Ø', 'V', '>']  prints Ø>>>>Ø V V Ø>>>>Ø V V Ø>>>>Ø  ## Javascript (ES6), 64 bytes (h,v,e,V,H)=>(v=(h=e+H.repeat(h-2)+e)+${V}.repeat(v)+
)+v+h


### Example

let f =
(h,v,e,V,H)=>(v=(h=e+H.repeat(h-2)+e)+
${V}.repeat(v)+ )+v+h console.log(f(8,3,'+','@','#')) • Does this handle the special case of no input? – Conor O'Brien Sep 3 '16 at 17:00 • { "message": "Script error.", "filename": "", "lineno": 0, "colno": 0 } when run inline. – noɥʇʎԀʎzɐɹƆ Sep 3 '16 at 22:41 • @AgentCrazyPython - Run on IE? It has no support for .repeat() – Arnauld Sep 3 '16 at 22:54 • @Arnauld naw, safari – noɥʇʎԀʎzɐɹƆ Sep 3 '16 at 23:34 • oh, it's ES6... – noɥʇʎԀʎzɐɹƆ Sep 3 '16 at 23:34 # V, 18 bytes älJxxÀPjddÀpkäGYGp  Try it online! # R, 80 bytes Pretty repetitive : function(h,v,a,b,c)cat(t<-c(a,rep(c,h),a,"\n"),d<-rep(c(b,"\n"),v),t,d,t,sep="")  Ungolfed : function(h,v,a,b,c) cat(t<-c(a,rep(c,h),a,"\n"), d<-rep(c(b,"\n"),v), t,d,t, sep="")  ## Pyke, 16 15 bytes *2mtz:zn+Q*' +D  Try it here! # Pyth, 19 bytes jP*3,++Jw*-E2wJj*Ew  A program that takes newline-separated input on STDIN of the corner character, number of horizontal characters, horizontal character, number of vertical characters and the vertical character, and prints the result. Try it online How it works jP*3,++Jw*-E2wJj*Ew Program. Jw Get the corner character. Store in J E Get the number of horizontal characters - 2 -2 * w Get the horizontal character and repeat it that many times + Add J at the beginning of that + J and at the end E Get the number of vertical characters * w Get the vertical character and repeat it that many times j Join the above on newlines , Construct a 2-element list from the horizontal and vertical strings *3 Repeat it 3 times P Everything except the last element j Join the above on newlines Implicitly print  # MATLAB, 95 92 91 85 81 bytes MATLAB 'E' function. (edit: doesn't work on Octave) function a=e(n,m,c,h,v);a(1:n)=h;a=[c a c];a(2:m+1,1)=v;a=[a;a;a];a=a(1:3+2*m,:);  And ungolfed: function a=e(n,m,c,h,v); %Declare the function a(1:n)=h; %Initialise return with top line excluding the corners a=[c a c]; %Then add corner pieces a(2:m+1,1)=v; %Next add the first vertical part a=[a;a;a]; %Repeat three times vertically to get an E with a tail a=a(1:3+2*m,:); %And then lop off the tail  The function should be called like: e(5,2,'*','-','|')  Which will return: +-----+ | | +-----+ | | +-----+  This can probably be simplified a bit, I'll keep working on it. I don't like having the entire function declaration to get the input, so will see if I can improve that. • Saved 3 bytes by simplifying generation of first line to first make the line without corners and then add the corners as this reduces the number of times indexing is required. • Another byte saved by starting with the first corner. • 6 more bytes by replacing repmat(a,3,1) call with [a;a;a]. • Saved 4 bytes by using a without specific initialisation (it's already declared in the function declaration) - thanks @LuisMendo • @LuisMendo interesting. I originally had a=[c a c] in there but removed it to shrink things down as normally you can't index access a non-existent variable and create it in the process. I forgot that this was a function so a is already declared in the function declaration as the return value. Thanks :) – Tom Carpenter Sep 4 '16 at 3:11 • In fact you can do it even if not in a function - indexing a non-existent variable does create it. Learn new things every day. – Tom Carpenter Sep 4 '16 at 3:17 ## Perl, 40 + 1 (-n) = 41 bytes Thanks to @Ton Hospel for saving 14 bytes and allowing the program to work with entry greater than 10. /.$/;$,=$/.<>x<>;say+($.$&x(<>-2).$)x3  Need -n as well as -E (or -M5.010) to run. For instance : perl -nE '/.$/;$,=$/.<>x<>;say+($.$&x(<>-2).$)x3' <<< '^$
!
4
9'

• @TheBitByte Ok great, it's done, thanks. – Dada Sep 3 '16 at 23:40
• This is already very good. But you can play a bit with the input format and also solve the flaw that the challenge does not say the repeats are < 10 by putting /(.)(.)/;$,=$' x<>;say+($1.$2x(<>-2).$1.$/)x3 in a file (since it uses $') and calling with perl -M5.010 -n prog.pl <<< '^!S\n4\n9' (use real newlines) which counts as 48 bytes (2 extra handicap since it cannot be combined with -e) – Ton Hospel Sep 4 '16 at 9:45 • @TonHospel Thanks. Right, I had not even noticed that this wouldn't work with numbers >10.. Great work with the input format, thanks. – Dada Sep 4 '16 at 11:23 • This is getting close to abusing the freedom to select the input format, but: perl -nE '/.$/;$,=$/.<>x<>;say+($.$&x(<>-2).$)x3' <<< '^$\n!\n4\n9' is 41 bytes (no more $') and also gets rid of the spurious trailing newline – Ton Hospel Sep 4 '16 at 17:04 • @TonHospel Indeed, I came up with that solution after your first suggestion, but I wasn't too comfortable with it because of the input format... Since we both thought about it, I changed my answer, but still, I feel like it's a bit cheaty... – Dada Sep 4 '16 at 20:23 # Dyalog APL, 31 29 bytes Prompts for horizontal-character, width, junction-character, height, vertical-character – in that order. h↓⊃⍪/3/⊂↑(⍞⍴⍨h←⎕),⊂⍞{∊⍺⍵⍺}⎕⍴⍞  ⎕⍴⍞ input-horizontal-character and repeat input-width times ( below) ⍞{...} input-junction-character which will be in the function... ∊⍺⍵⍺ flatten [[junction],[horizontals],[junction]] ⊂ encapsulate so it can be part of a list (...), prepend... h←⎕ input-height ⍞⍴⍨ input-vertical-character and repeat it that many times ↑ make the list of strings into a character table ⊂ encapsulate (so it can be repeated as a whole) 3/ repeat it three times ╻ ╻ ╻ ┗━ ┗━ ┗━  ⍪/ concatenate the three pieces vertically ╻ ┣━ ┣━ ┗━  (this encapsulates them too, so we need to...) ⊃ remove the encapsulation h↓ drop the first h (rows) ┏━ ┣━ ┗━  TryAPL online! ## C, 130 bytes #define p putchar #define E for(o=0;o++<O;p(10))p(S); #define W for(p(P),D=0;D++<C-2;)p(_);p(P);p(10); f(C,O,P,S,_,D,o){W E W E W}  ### Usage: main(){f(7,2,'+','|','-');}  Output +-----+ | | +-----+ | | +-----+  • Removing the semicolons in defines and adding it as f(C,O,P,S,_,D,o){W;E;W;E;W;} saves a byte. – betseg Sep 28 '16 at 16:44 # C#, 108 bytes (m,n,e,v,h)=>{string x=e+new string(h,m-2)+e+"\n",y=new string(v,n).Replace(v+"",v+"\n");return x+y+x+y+x;};  Anonymous function which generates each horizontal and vertical line and builds the final output. Ungolfed function: (m,n,e,v,h)=> { string x = e + new string(h, m - 2) + e + "\n", y = new string(v, n).Replace(v + "", v + "\n"); return x + y + x + y + x; };  Full program with test cases: using System; namespace LetterEWithoutE { class Program { static void Main(string[] args) { Func<int,int,char,char,char,string>f= (m,n,e,v,h)=>{string x=e+new string(h,m-2)+e+"\n",y=new string(v,n).Replace(v+"",v+"\n");return x+y+x+y+x;}; Console.WriteLine(f(7,2,'+','|','-')); Console.WriteLine(f(7,2,'@','|','-')); Console.WriteLine(f(7,2,'@','|','#')); Console.WriteLine(f(8,3,'+','|','#')); Console.WriteLine(f(8,3,'+','@','#')); Console.WriteLine(f(9,4,'^','$','!'));
}
}
}


# MATL, 15 bytes

Thanks to @muddyfish for a correction

2-Y"yv!iiY"!yyy


Try it online!

### Explanation

The stack contents after each step are indicated for clarity, using the first example in the challenge.

2-    % Implicitly input number of repetitions of the char of the horizontal line.
% Subtract 2
%   STACK: 5
Y"    % Implicitly input char of the horizontal line. Apply run-length decoding
%   STACK: '-----' (string)
y     % Implicitly input (from below) the char of the corners. Duplicate onto the top
%   STACK: '+', '-----', '+'
v!    % Concatenate all the stack horizontally. We now have the horizontal line
% including the corners
%   STACK: '+-----+'
iiY"  % Take two inputs: char of the vertical line and number of repetitions
%   STACK: '+-----+', '||'
!     % Transpose. This tranforms the string into a vertical char array, which
% gives the vertical line
%   STACK: '+-----+', ['|';'|'] (vertical char array)
y     % Duplicate from below: this pushes a new copy of the horizontal line
% onto the top of the stack
%   STACK: '+-----+', ['|';'|'], '+-----+'
y     % Duplicate from below: this pushes a new copy of the vertical line
% onto the top of the stack
%   STACK: '+-----+', ['|';'|'], '+-----+', ['|';'|'],
y     % Duplicate from below: this pushes a new copy of the horizontal line
% onto the top of the stack
%   STACK: '+-----+', ['|';'|'], '+-----+', ['|';'|'], '+-----+'
% Implicitly display


# Bash + coreutils, 105 bytes

printf -- "$3printf -- "$4%.0s" $(seq$1)$3printf "\n$5%.0s" $(seq$2)%.0s\n" {1..3}|sed -n 1,$(($2*2+3))p


Assuming the file within which this is stored is named A.sh, the usage would be:

bash A.sh <Horizontal Segment Length w/out Edge Chars> <Vertical Segment Length> '<Left/Right Edge Char>' '<Char Between Edges>' '<Vertical Char>'


The -- are needed, just in case one of the character inputs happens to be a -, and printf apparently doesn't handle dashes in the beginning of a string very nice without the double-dashes.

## Explanation

Assuming that the input is 5 2 + * |...

1. $3printf -- "$4%.0s" $(seq$1)$3printf "\n$5%.0s" $(seq$2)

Create the first horizontal segment and vertical segment all together. This would result in:

+*****+
|
|

2. printf -- "$3printf -- "$4%.0s" $(seq$1)$3printf "\n$5%.0s" $(seq$2)%.0s\n" {1..3}

Repeat the previously created part 3 times over. This now results in:

+*****+
|
|
+*****+
|
|
+*****+
|
|

3. printf -- "$3printf -- "$4%.0s" $(seq$1)$3printf "\n$5%.0s" $(seq$2)%.0s\n" {1..3}|sed -n 1,$(($2*2+3))p

Finally pipe the previous output to sed to get rid of the last 2 line segments by only outputting the first <Vertical Segment Length>*2+3 lines of the E. We finally get the E we want:

+*****+
|
|
+*****+
|
|
+*****+


## PowerShell v2+, 60 59 bytes

param($a,$b,$c,$d,$e)(,($x="$c$($e*($a-2))$c")+,$d*$b)*2;$x


Takes input as individual command-line arguments. Constructs the horizontal string, stores that into $x for use later, then forms that into an array with the comma-operator ,. Performs array concatenation (i.e., adding elements to the end) of $d formulated into an array of $b elements. That, in turn, is formulated into an array of two elements with another comma operator, and is left on the pipeline. Then, the horizontal $x is left on the pipeline. Abuses the default formatting of Write-Output to put a newline between elements.

### Example

PS C:\Tools\Scripts\golfing> .\the-letter-e-without-e.ps1 5 3 "z" "v" "d"
zdddz
v
v
v
zdddz
v
v
v
zdddz


# Python 3, 60 bytes

A Function

def p(a,b,c,d,e):q=c+e*(a-2)+c;return(q+'\n'+(d+'\n')*b)*2+q


Test Case

>>> print(p(8,2,'+','|','#'))
+######+
|
|
+######+
|
|
+######+

• you have 2 too many dashes in the output – Blue Sep 3 '16 at 20:05

# Brainf*ck, 147 bytes

,>,>++++++++[<------<------>>-]<<-->>>,>,>,>+++>++>++++++++++<<[-<<<.<<<[->>+>>>.<<<<<]>>[-<<+>>]>.>>>>>.<[-<<<<<<[->+>>.>>>>.<<<<<<<]>[<+>-]]>>>>]


Takes input from stdin as first 5 characters entered. The first two are have 48 subtracted from their ASCII code so 0-9 behave as expected. For numbers > 9, add 48 to the number and use the corresponding character. The other three characters are as specified in the challenge.

I'm sure it's not the optimal solution but life is too short to golf brainf*ck.

[
Input: number number corner vertical horizontal
Numbers are single digits; add 48 and use the ASCII character corresponding
to the number you want for numbers > 9.
First number is the number of characters across. Second is the number down.

Layout: {first number-2} {second number} {temp} {a} {b} {c}
]

,>,>++++++++[<------<------>>-]<<-->>>,>,>,
now we should have the first five cells with the specified layout
the 6th will hold 3 as a counter and the 7th 2 and the 8th 10 '\n'

>+++>++>++++++++++<<
[  while the 6th cell is not 0
-
<<<.    print corner
<<<[->>+>>>.<<<<<]  print horizontal characters
>>[-<<+>>]         copy temp back to 1st cell
>.>>>>>.           print corner and newline
<
[ If the second counter is not zero
-
<<<<<<[->+>>.>>>>.<<<<<<<]  print vertical and newline n times
>[<+>-]           copy temp back to 2nd cell
]
>>>>
]


Example run:

sean@SEANSBOX:~/Dropbox/Code/BF$./bf E.b 94^$!
^!!!!!!!^


^!!!!!!!^


^!!!!!!!^


# PHP, 97 bytes

list(,$w,$h,$c,$v,$r)=$argv;echo$b=str_pad($a=str_pad($c,++$w,$r)."$c\n",--$h*2+$w,"$v\n"),$b,$a;  no loop, only builtins. Run with php -r '<code>' <parameters>. # Java 7, 205 129 bytes String c(int w,int h,String a,char b,char c){String r=a,n="\n",l="";for(;w-->2;r+=c);r+=a+n;for(;h-->0;l+=b+n);return r+l+r+l+r;}  -76 bytes thanks to an anonymous stranger. PS: Don't go edit other people's posts next time. If you have something to golf please leave it as a comment, or if it's using a completely different approach you could make your own answer. Still thanks for golfing away all these bytes, though - whoever you are.. Ungolfed & test cases: Try it here. class M { static String c(int w, int h, String a, char b, char c){ String r = a, n = "\n", l = ""; for(; w-- > 2; r += c); r += a+n; for( ;h-- > 0; l += b+n); return r+l+r+l+r; } public static void main(String[] a) { System.out.print(c(7, 2, "+", '|', '-')); System.out.print(c(9, 4, "?", '¡', '¿')); } }  Output: +-----+ | | +-----+ | | +-----+ ?¿¿¿¿¿¿¿? ¡ ¡ ¡ ¡ ?¿¿¿¿¿¿¿? ¡ ¡ ¡ ¡ ?¿¿¿¿¿¿¿?  Racket 124 bytes (λ(w h a b c)(for((i 3))(display a)(for((i w))(display c))(display a)(when(< i 2)(displayln "")(for((j h))(displayln b)))))  More readable form: (define(f w h a b c) (for((i 3)) (display a) (for((i w)) (display c)) (display a) (when(< i 2) (displayln "") (for((j h)) (displayln b)))))  Testing: (f 7 2 "+" "|" "-" ) +-------+ | | +-------+ | | +-------+  # C++, 121 Bytes #import<string> #import<iostream> #define f(w,h,C,W,H){std::string s(w,W),t;s=C+s+C+"\n";for(int i=h;i--;)t=t+H+"\n";std::cout<<s+t+s+t+s;}  Ungolfed: #import<string> #import<iostream> #define f(w,h,C,W,H){ std::string s(w,W),t; //define two strings, one empty, one with horizontal characters s = C+s+C+"\n"; //assemble a horizontal bar for(int i=h;i--;) t=t+H+"\n"; //assemble a vertical bar std::cout<<s+t+s+t+s; //print }  In C++ its not allowed to declare functions without type as in C. But macros that behave just like a function are totally possible. Note also that the ungolfed version will not compile until you add a "\" to each but the last line of the macro. You might save two additional bytes by removing the {}, but then you can't use the macro twice in a row. Usage: int main() { f(4,2,'+','-','|') f(2,1,'@','#','i') return 0; }  Output: +----+ | | +----+ | | +----+ @##@ i @##@ i @##@  Try it online # CJam, 23 bytes riri)N*r2*\r*\@r**a3*\*  Try it online! The input is is in the given order, but should be space separated instead of using a comma. Some of the difficulty is getting the input the right order for CJam's join operation *; for comparison rearranging the input in could save 4 bytes. If the inputs are dubbed A B C D E then the program works something like this: ri e# get A as integer ri)N* e# create B+1 newlines r2* e# create 2 Cs \r* e# join newlines with D (hereafter ND) \@ e# bring A & Cs to the front r* e# create A Es * e# join, puts Es between Cs (hereafter CEC) a3* e# makes 3 copies of CEC strings \* e# join, puts NDs between CECs  ## Lua(5.2), 144 bytes k,a,p,q=loadstring,arg,io.write,print l,d=k"for i=3,a[1]do p(a[5])end",k"for i=1,a[2]do q(a[4])end"b=a[3]p(b)l()q(b)d()p(b)l()q(b)d()p(b)l()p(b)  Try it online! (Coding Ground) It should output something like that right now: +@@@@@+ l l +@@@@@+ l l +@@@@@+  Own input: 7 2 + l @ You can change the input in project->compile options and there change the values, each value as in the example but not separated by commas but by spaces. ## QBIC, 44 bytes ::;;;X=A[q,a-2|X=X+C]X=X+A ?X[1,2|[1,b|?B]?X  Explanation ::;;; Get the input parameters, 2 numbers and 3 strings X=A[q,a-2|X=X+C]X=X+A Build the horizontal string: The corner string, x-2 times the filler string and another corner ?X Print the horizontal string [1,2| Do the next thing twice [1,b|?B]?X Print the right number of vertical strings, then the horizontal string.  # PHP, 94 Bytes <?list($v,$h,$p,$d,$r)=$_GET[a];for($h++;$i<=2*$h;)echo$i++%$h?$d:str_pad($p,$v-1,$r).$p,"\n";  Input format an array in the same order as the suggested string • If you use ,"\n" instead of ."\n", you can drop the parens for the ternary. – Titus Oct 17 '16 at 14:20 • for($h++;$i<=2*$h;) and $i++%$h saves another byte. – Titus Oct 17 '16 at 14:24
• \$v-1 gives only 3 horizontal characters for [5,2,+,|,-]. Number of horizontal characters, not including the left and right edge characters – Titus Oct 17 '16 at 14:37
• @Titus that is right, I have rollback your edit. 5 Horizontal means 3 Characters with 2 edges = 5. Make look at the question. And for the others ideas Thank You – Jörg Hülsermann Oct 17 '16 at 14:46