[Question]
  [
Your task is to generate boxes using any one ASCII character with respect to the inputs given.
# Test Cases
```
1 1   --> =====
          =   =
          =====
1 2   --> =========
          =   =   =
          =========
2 1   --> =====
          =   =
          =====
          =   =
          =====
2 2   --> =========
          =   =   =
          =========
          =   =   =
          =========
2 5   --> =====================
          =   =   =   =   =   =
          =====================
          =   =   =   =   =   =
          =====================
```
# Input
* Input can be taken from one of the following
	+ `stdin`
	+ Command-line arguments
	+ Function arguments (2 arguments, one for each number)
* Input, if taken from `stdin` or command line arguments, will contain two positive integers, seperated by a space.
* The two numbers denote the number of boxes in each column and row
# Output
* Boxes must be outputted in `stdout` (or closest equivalent)
* Each box should have three horizontal spaces in them
# Rules
* Both the numbers will be greater than 0, but will not go beyond 1000
* Any visible character can be used for outputting the boxes. (as long as they aren't too harsh on the eye!)
* You are permitted to write a full program or a function.
* There should be no unnecessary characters except an optional trailing newline character.
# Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest submission (in bytes) wins.
  
[Answer]
# Pyth, 23 bytes
```
Mjbmsm@"= "&%k4dh*4HhyG
```
Defines the function `g` which works as desired.
[Demonstration.](https://pyth.herokuapp.com/?code=Mjbmsm%40%22%3D%20%22%26%25k4dh*4HhyGg2%205&debug=0)
[Answer]
# [Retina](https://github.com/mbuettner/retina), 57 bytes
```
1(?=.* (1*))
$1#$1#
1(?=(1*#1*#)*$)
=   
1
====
#
=#
```
Takes input in unary with a trailing newline.
Each line should go to its own file and `#` should be changed to newline in the files. This is impractical but you can run the code as is as one file with the `-s` flag, keeping the `#` markers (and changing the trailing newline to `#` in the input too). You can change the `#`'s back to newlines in the output for readability if you wish. E.g.:
```
> echo -n 11 111#|retina -s boxes|tr # '\n'
=============
=   =   =   =
=============
=   =   =   =
=============
```
Method: 5 single substitution steps. The first two (first 4 lines) creates an `2*N+1` by `M` grid of ones and the next 3 steps (6 lines) format it into the desired output.
The intermediate strings (delimited by `-`'s):
```
11 111
------------------
111
111
111
111
 111
------------------
111
111
111
111
111
------------------
111
=   =   =   
111
=   =   =   
111
------------------
============
=   =   =   
============
=   =   =   
============
------------------
=============
=   =   =   =
=============
=   =   =   =
=============
```
[Answer]
# JavaScript (*ES6*), 83
A function with parameters rows and columns. Using template strings, there are 2 embedded newlines that are significant and counted.
Output via `alert` (popup).
As `alert` use a proportional font, we get a better result using a letter with a width similar to the space instead of `=`.
Test in Firefox using the console to have the real `alert` output, or run the snippet below.
```
f=(r,c)=>{for(x=y="|";c--;)x+="||||",y+="   |";for(o=x;r--;)o+=`
${y}
`+x;alert(o)}
// TEST
// redefine alert to avoid that annoying popup during test
alert=x=>O.innerHTML=x
test=_=>([a,b]=I.value.match(/\d+/g),f(a,b))
test()
```
```
<input id=I value='2 3'><button onclick="test()">-></button>
<pre id=O></pre>
```
[Answer]
# JavaScript (ES6), ~~75~~ 73
Using copious `repeat` calls, we repeat `|`, then repeat `|` with trailing spaces, and repeat both of those repeats to make rows:
```
f=(y,x)=>alert(((s="|"[r="repeat"](x*4)+`|
`)+"|   "[r](x)+`|
`)[r](y)+s)
```
(Newlines are significant, per edc65's suggestion to use template strings.)
Snippet:
```
<input id="x" type="range" max="10" min="1" step="1" value="3"><input id="y" type="range" max="10" min="1" step="1" value="2"><pre id="o"></pre><script>function f(y,x){return ((s="|"[r="repeat"](x*4)+"|\n")+"|   "[r](x)+"|\n")[r](y)+s};function redraw(){document.getElementById("o").innerHTML=f(document.getElementById("y").value,document.getElementById("x").value)};document.getElementById("x").onchange=redraw;document.getElementById("y").onchange=redraw;document.getElementById("x").oninput=redraw;document.getElementById("y").oninput=redraw;redraw();</script>
```
Without template strings, without method-name reuse, and with added whitespace:
```
f=(y,x)=>alert(
    (
      (s="|".repeat(x*4)+"|\n") + 
      "|   ".repeat(x)+"|\n"
    ).repeat(y)+s
)
```
(Using [edc65's recommendation](https://codegolf.stackexchange.com/a/51565/7796) to use `|` for better visual spacing.)
[Answer]
# Pip, ~~29~~ 24 = 23 + 1 bytes
Requires the `-n` flag. Takes the height and width as command-line args and builds boxes of of `1`s.
```
([1X4m]XbRLa+1)@<v.1R0s
```
Explanation:
```
                         a,b are cmdline args; m is 1000; v is -1; s is " " (implicit)
 [1X4m]                  List containing 1111 and 1000
       Xb                String repetition of each element b times
         RLa+1           Repeat the list a+1 times
(             )@<v       Now we have one row too many at the end, so take everything
                         but the last item (equiv to Python x[:-1])
                  .1     Concatenate a 1 to the end of each row
                    R0s  Replace 0 with space
                         Print, joining list on newlines (implicit, -n flag)
```
This program takes heavy advantage of the fact that strings are numbers and numbers are strings in Pip. (And the three spaces in those boxes happened to be just right to take advantage of the built-in `m` variable!)
Here's how the list gets built with the input `2 3`:
```
[1111;1000]
[111111111111;100010001000]
[111111111111;100010001000;111111111111;100010001000;111111111111;100010001000]
[111111111111;100010001000;111111111111;100010001000;111111111111]
[1111111111111;1000100010001;1111111111111;1000100010001;1111111111111]
[1111111111111;"1   1   1   1";1111111111111;"1   1   1   1";1111111111111]
```
And the final output:
```
C:\> pip.py 2 3 -ne "([1X4m]XbRLa+1)@<v.1R0s"
1111111111111
1   1   1   1
1111111111111
1   1   1   1
1111111111111
```
[More on Pip](http://github.com/dloscutoff/pip)
[Answer]
## Perl, ~~72~~ ~~63~~ ~~52~~ 50 bytes
My shortest version yet uses `$/` to get a newline char more compactly:
```
$ perl -e 'print((($,="="."   ="x pop.$/)=~s/./=/gr)x(1+pop))' 2 5
=====================
=   =   =   =   =   =
=====================
=   =   =   =   =   =
=====================
```
The previous update puts the mostly empty lines in the output record separator `$,`, and prints a list of continuous lines.
```
$ perl -e 'print((($,="="."   ="x pop."\n")=~s/./=/gr)x(1+pop))' 2 5
```
The previous version might be a bit clearer for the casual reader:
```
$ perl -E 'say($y=($x="="."   ="x pop)=~s/./=/gr);for(1..pop){say$x;say$y}' 2 5
```
The first version used `@ARGV` instead of `pop`:
```
$ perl -E 'say($y=($x="="."   ="x$ARGV[1])=~s/./=/gr);for(1..$ARGV[0]){say$x;say$y}' 2 5
```
[Answer]
# Python 2, ~~58~~ 57 Bytes
Fairly straightforward implementation.
```
def f(x,y):a="="*(4*y+1);print(a+"\n="+"   ="*y+"\n")*x+a
```
[Check it out here.](http://ideone.com/EXXCox)
*Thanks to Sp3000 for saving one byte.*
[Answer]
# GNU sed -r, 160
Sigh, I thought this would be smaller, but here it is anyway. Unfortunately sed regexes don't have any lookaround capability.
```
:
s/(.*)1$/   =\1/;t
s/([= ]+)/\1\n\1/
:b
s/   (.*\n)/===\1/;tb
s/(1*)1 $/\n\1/
:c
s/([^\n]*\n[^\n]*\n)(1*)1$/\1\1\2/;tc
s/(=+)(.*)/\1\2\1/
s/(^|\n)(.)/\1=\2/g
```
Taking input as unary from STDIN:
```
$ sed -rf boxes.sed <<< "11 111"
=============
=   =   =   =
=============
=   =   =   =
=============
$
```
[Answer]
# CJam, 25 bytes
```
q~)S3*'=5*+4/f*3f>\)*1>N*
```
Try it online in the [CJam interpreter](http://cjam.aditsu.net/#code=q~)S3*'%3D5*%2B4%2Ff*3f%3E%5C)*1%3EN*&input=2%205).
### How it works
```
q~                        e# Read H and W from STDIN.
   S3*'=5*+               e# Push "   =====".
           4/             e# Chop into ["   =" "===="].
  )          f*           e# Repeat each string W+1 times.
               3f>        e# Cut off the first three characters.
                  \)*     e# Repeat the resulting array H+1 times.
                     1>   e# Remove the first string.
                       N* e# Join the lines.
```
[Answer]
# Marbelous, 168 bytes
This answer only works up to 255x255, not 1000x1000, due to limitations of the Marbelous language. I'm working on a 32-bit library, but it's not going to be ready any time soon.
Input is provided as two command line parameters or function parameters to the main board.
```
@2@3}1@0
SLEL//>0\/
@3@1}0--
}1&0@0/\&0
@1/\@2}1\/
:SL
..}0@0
&0/\>0&0
EN..--\/
{0@0/\ES
:EL
..@0
..>0EN
}0--\/
@0/\EX
:EX
}0
\/3D3D3D3D
:ES
}0
\/3D202020
:EN
}0
{03D0A
```
Pseudocode:
```
MB(H,W):
    EL(W)
    for 1..H:
        SL(W)
        EL(W)
EL(W):
    for 1..W:
        EX()
    EN()
SL(W):
    for 1..W:
        ES()
    EN()
EX():
    print "===="
ES():
    print "=   "
EN():
    print "=\n"
```
[Answer]
# CJam ~~52~~ ~~51~~ ~~46~~ 41 bytes
```
l~:B;:A;'=:U{{U4*}B*N}:V~{U{SZ*U}B*NUV}A*
```
Thanks to Sp3000 for -5 chars
Thanks to Martin Büttner♦ for another 5 chars
[Try it](http://cjam.aditsu.net/#code=l%7E%3AB%3B%3AA%3B%27%3D%3AU%7B%7BU4*%7DB*N%7D%3AV%7E%7BU%7BSZ*U%7DB*NUV%7DA*&input=2%203)
[Answer]
# c function, 81
```
x,y;f(h,w){for(;y<=h*2;y++)for(x=0;x<w*4+2;x++)putchar(x>w*4?10:x&3&&y&1?32:61);}
```
### Test program:
```
x,y;f(h,w){for(;y<=h*2;y++)for(x=0;x<w*4+2;x++)putchar(x>w*4?10:x&3&&y&1?32:61);}
int main (int argc, char **argv)
{
  f(2, 3);
}
```
[Answer]
# PHP4.1, ~~76~~ ~~71~~ 69 bytes
This is as golfed as I can get.
```
$R=str_repeat;echo$R(($T=$R('-',4*$H+1))."
|{$R('   |',$H)}
",$V),$T;
```
This expects the key `H` to have the number of lines and `V` the number of boxes per line.
I'm using `-` and `|` just so the boxes actually look like boxes. If required, I can change it to `=`. It doesn't matter the char that is used.  
Leaving `-` and `|` also helps to understand the mess that's going on.
---
Old method, 76 bytes:
```
for($R=str_repeat;$H--;)echo$T=$R('-',($V*4)+1),"
|{$R('   |',$V)}
";echo$T;
```
---
Example of output:
```
http://localhost/file.php?H=2&V=3
-------------
|   |   |   |
-------------
|   |   |   |
-------------
```
[Answer]
# Julia, 59 bytes
```
(n,m)->(l="="^(4m+1)*"\n";print(l*("="*"   ="^m*"\n"*l)^n))
```
This creates an unnamed function that accepts two integers as input and prints the result to STDOUT. To call it, give it a name, e.g. `f=(n,m)->...`.
Ungolfed + explanation:
```
function f(n, m)
    # Store the solid row
    l = "="^(4m + 1) * "\n"
    # Print all rows by repeating a pattern n times
    print(l * ("=" * "   ="^m * "\n" * l)^n)
end
```
Examples:
```
julia> f(2, 3)
=============
=   =   =   =
=============
=   =   =   =
=============
julia> f(1, 5)
=====================
=   =   =   =   =   =
=====================
```
Any suggestions are welcome.
[Answer]
# bash + coreutils, 57
```
dc -e"2do$2 4*1+^1-pd8*F/1+$1si[fli1-dsi0<c]dscx"|tr 0 \ 
```
This uses `dc` to print binary numbers that have `1`s for the box edges and `0`s for the spaces.
* the all-ones number **X** is calculated by `2 ^ (width * 4 + 1) - 1`, then pushed and printed
* the `10001...0001` number is calculated by **`X`**`* 8 / 15 + 1`, then pushed
* the stack is then dumped `height` times
The `tr` then converts the `0`s to space characters.
### Output
```
$ ./boxes.sh 2 4
11111111111111111
1   1   1   1   1
11111111111111111
1   1   1   1   1
11111111111111111
$ 
```
[Answer]
# R, ~~83~~ 81
As an unnamed function taking h and w as parameters.
Builds the 1st and second lines into a vector for each row and replicates it `h` times. Appends a vector for the bottom line and `cat`s out the vector using `fill` to restrict the length of the lines. Now takes advantage of the any visible character rule.
```
function(h,w)cat(rep(c(A<-rep(1,w*4+2),rep('   1',w)),h),A[-1],fill=w*4+1,sep='')
```
Test run
```
> f=function(h,w)cat(rep(c(A<-rep(1,w*4+2),rep('   1',w)),h),A[-1],fill=w*4+1,sep='')
> f(4,2)
111111111
1   1   1
111111111
1   1   1
111111111
1   1   1
111111111
1   1   1
111111111
> 
```
[Answer]
# Python ~~3~~ 2, ~~160~~ ~~87~~ ~~85~~ 79 bytes
I know this can be golfed a ***lot*** more, I would like some suggestions as this is my first try at golfing.
```
def d(x,y):
    for i in[1]*x:print'='*(4*y+1)+'\n'+'=   '*(y+1)
    print'='*(4*y+1)
```
Thanks to @Cool Guy and @Sp3000's tips, I narrowed the size down to just ~~above~~ below half.
Eg: d(3,3)
```
=============
=   =   =   =   
=============
=   =   =   =   
=============
=   =   =   =   
=============
```
[Try it out here](http://ideone.com/KyKaXo).
Excuse the trailing whitespaces.
[Answer]
# KDB(Q), 37 bytes
```
{(3+2*x-1)#(5+4*y-1)#'(4#"=";"=   ")}
```
# Explanation
```
                      (4#"=";"=   ")     / box shape
           (5+4*y-1)#'                   / extend y axis
 (3+2*x-1)#                              / extend x axis
{                                   }    / lambda
```
# Test
```
q){(3+2*x-1)#(5+4*y-1)#'(4#"=";"=   ")}[2;5]
"====================="
"=   =   =   =   =   ="
"====================="
"=   =   =   =   =   ="
"====================="
```
[Answer]
# JavaScript, ~~92~~ 85 bytes
I had hoped this would be shorter than the other JS answer (nice work as always, edc65), but oh well. I have a feeling the math here can be further golfed.
```
f=(r,c)=>(x=>{for(i=s='';(y=i++/x)<r-~r;)s+=i%x?' *'[-~y%2|!(-~i%4)]:'\n'})(4*c+2)||s
```
[Answer]
# Octave, ~~69~~ ~~65~~ 64
```
y=ones([2,4].*input()+1);y(1:2:end,:)=y(:,1:4:end)=4;char(y+31)
```
Thanks to DLosc for pointing out issues that led to -1
Takes input as `[1 1]` and outputs:
```
#####
#   #
#####
```
You can also just input '1' and get 1x1. If the input really needs to be `1 1`, the size goes up to **~~88~~ ~~85~~ 84**:
```
y=ones([2,4].*eval(['[',input(0,'s'),']'])+1);y(1:2:end,:)=y(:,1:4:end)=4;char(y+31)
```
Note: Matlab doesn't allow Octave's chaining or input(integer), but here is the Matlab version (**67**):
```
y=ones([2,4].*input('')+1);y(1:2:end,:)=4;y(:,1:4:end)=4;char(y+31)
```
[Answer]
# C, 76 bytes
```
w,n;f(r,c){for(w=c*4+2,n=w*r*2+w;n--;)putchar(n%w?n/w%2&&n%w%4-1?32:61:10);}
```
Invoked as a function with number of rows and columns as arguments. For example:
```
f(5, 2)
```
[Answer]
# CJam, ~~30~~ 29 bytes
New version with redundant `+` at the end removed (thanks, Dennis):
```
l~_4*)'=*N+:F\'=S3*+*'=+N++*F
```
I know that Dennis already posted a CJam solution that beats this by miles. But this is my very first attempt at CJam, so it's a miracle that it works at all. :)
Fairly brute force. Builds the first line from `4 * H + 1` `=` signs, then the second line from `=` repeated `H` times, with another `=` added. Then concatenates the two lines, repeats the whole thing `V` times, and then adds another copy of the first line.
It feels like I have way too many stack manipulations, and even ended up storing the first line in a variable because I had to shuffle stuff around on the stack even more otherwise.
Not very elegant overall, but you have to start somewhere... and I wanted to try a simple problem first.
[Answer]
# CJam, 23
```
q~[F8]f{2b*1+' f+N}*_0=
```
[Try it online](http://cjam.aditsu.net/#code=q~%5BF8%5Df%7B2b*1%2B'%20f%2BN%7D*_0%3D&input=3%205)
**Explanation:**
```
q~        read and evaluate the input (height width)
[F8]      make an array [15 8] - 1111 and 1000 in base 2
f{…}      for width and each of [15 8]
  2b      convert the number to base 2
  *       repeat the digits "width" times
  1+      append a 1 to the array of digits (right edge)
  ' f+    add the space character to each digit (0->' ', 1->'!')
  N       push a newline
*         repeat the resulting array "height" times
_0=       copy the first line (bottom edge)
```
[Answer]
# Dart, 57
```
b(y,x,{z:'='}){z+=z*4*x;print('$z\n=${'   ='*x}\n'*y+z);}
```
Try it at: <https://dartpad.dartlang.org/36ed632613395303ef51>
[Answer]
## Java, 181
I hope that according to 
> 
> You are permitted to write a full program or a function.
> 
> 
> 
it is compliant to the rules to count the bytes of the *function*, which is 181 in this case
```
import static java.lang.System.*;
public class Boxes
{
    public static void main(String[] args)
    {
        Boxes b=new Boxes();
        System.out.println("1,1:");
        b.b(1,1);
        System.out.println("1,2:");
        b.b(1,2);
        System.out.println("2,1:");
        b.b(2,1);
        System.out.println("2,2:");
        b.b(2,2);
        System.out.println("2,5:");
        b.b(2,5);
    }
    void b(int R, int C){String s="",e=s,x,y,z=s,a="====",n="=\n";int r,c;for(r=R;r-->0;){x=y=e;for(c=C;c-->0;){x+=a;y+="=   ";}s+=x+n+y+n;}for(c=C;c-->0;){z+=a;}s+=z+n;out.println(s);}
}
```
[Answer]
# C#, ~~153~~ ~~151~~ 150
This can't really compete but here it is just for fun:
```
(h,w)=>{string s="=",e="\n",a="====",b="   =",m=a,o;int i=0,j;for(;i++<=h*2;){o=s;for(j=0;j++<w+1;o=m)System.Console.Write(o);m=m==a?b:a;s=e+s;e="";}}
```
How to run:
```
public class Program
{
    public static void Main()
    {
        new System.Action<int, int>((h,w)=>{string s="=",e="\n",a="====",b="   =",m=a,o;int i=0,j;for(;i++<=h*2;){o=s;for(j=0;j++<w+1;o=m)System.Console.Write(o);m=m==a?b:a;s=e+s;e="";}})(3, 4);
    }
}
```
Open for improvements.
[Answer]
# Python 2.7, 66 bytes.
I know there are already better solutions in python, but that's the best I came up with.
```
def f(x,y):a,b,c="="*4,"   =","\n=";print "="+a*y+(c+b*y+c+a*y)*x
```
Example:
```
f(3,4)
=================
=   =   =   =   =
=================
=   =   =   =   =
=================
=   =   =   =   =
=================
```
[Answer]
## Ruby, ~~57~~ ~~48~~ 45
```
f=->h,w{l=?=*w*4+?=;(l+$/+'=   '*w+"=
")*h+l}
```
Usage:
```
print f[2,5]
```
Thanks to manatwork for saving 3 bytes.
[Answer]
# Java, ~~123~~ 119 bytes
```
void p(int h,int w){String b="=",d="\n=";for(;w-->0;d+="   =")b+="====";for(d+="\n"+b;h-->0;b+=d);System.out.print(b);}
```
Abusing the input parameters as counters greatly helped in decreasing code size.
Thanks to Cool Guy for suggesting the abuse of for syntax.
[Answer]
# SAS, 117 119
```
macro a array a[0:1]$4('#   ' '####');do x=1 to 2+2*&x-1;t=repeat(a[mod(x,2)],&y-1);put t $char%%eval(&y*3). '#';end;%
```
Example:
```
%let x=4;
%let y=4;
data;a;run;
```
Result:
```
#############
#   #   #   #
#############
#   #   #   #
#############
#   #   #   #
#############
#   #   #   #
#############
```
]