# Happy Bacon Day!

Today is Bacon Day which is probably why the name of the hat for participating today is "Mmmm Bacon". What better way to celebrate bacon day with fun filled 2d matrices made out of bacon! A 1 by 1 bacon strip is represented by this:

-----
)===)
(===(
)===)
-----


You goal here is given two coordinates in a tuple, (x, y), where x and y are nonzero positive integers, you are to create the bacon and return in some format (list, array, string).

Input and Output:

Input: (2, 1)

Output:
----------
)===))===)
(===((===(
)===))===)
----------

Input: (1, 2)

Output:

-----
)===)
(===(
)===)
-----
)===)
(===(
)===)
-----

Input: (2, 2)

----------
)===))===)
(===((===(
)===))===)
----------
)===))===)
(===((===(
)===))===)
----------


Rules:

• As you can see with the second test case, if multiple pieces of bacon are stacked together, only one ----- separates with each piece of bacon above and/or below it. That means stacking bacon like this is invalid:

-----
)===)
(===(
)===)
-----
-----
)===)
(===(
)===)
-----

• Standard loopholes are forbidden

• The code must work for the above test cases and the following: (4, 4), (1, 6), (5, 1), (2, 3), (3, 2)

• Provide an interpreter where the above test cases can be tested

Winning Criteria:

Shortest code wins! Happy Bacon Day to everyone!

• This conversation has been moved to chat. – Dennis Dec 31 '16 at 22:46

# V, 28, 26, 24 bytes

Ài)³=)Y4PÒ-G.MÓ)/(
kÀäG


Try it online!

Explanation:

Ài                      " Arg 1 times insert:
)³=)                  " ')===)'
<esc>             " Escape back to normal mode
Y            " Yank this line
4P          " Paste four times
Ò-        " Replace this line with '-'
G.      " Repeat on the last line
M     " Move to the middle line
Ó)/( " Replace ')' with '('
k                       " Move up (to the second line)
À                      " Arg 2 times
äG                    " Duplicate everything up to the last line

• I love how this answer is only 3 bytes longer than a single bacon :D – FlipTack Dec 30 '16 at 18:28
• @FlipTack There are Newlines. It's actually 2 shorter. :P – DJMcMayhem Dec 30 '16 at 18:29
• Forgot about that! Wow, an answer that's shorter than the building blocks of the output. This is some dennis-style stuff going on. – FlipTack Dec 30 '16 at 19:05

# TI-Basic, 80 bytes

This one was actually quite genius :)

":→Str0:Input :For(M,0,4Y:For(N,1,X:")===)
If not(fPart(M/4:"-----
If .5=fPart(M/4:"(===(
Str0+Ans→Str0:End:Ans+":→Str0:End

• Also, for anyone wondering, in TI-Basic the colon and newline are interchangeable, and using Input with no arguments gets input by default into X and Y. – Timtech Dec 30 '16 at 21:45

# Python 2.7, 74 bytes

I'm sure this could be golfed some more, but this is what I came up with (Python's string multiplication feature sure comes in handy):

a,b=input();f="-"*5*a;d=")===)"*a;print'\n'.join([f,d,"(===("*a,d,''])*b+f


Ungolfed with explanation:

a,b = input()                                       # Take input from the user as a tuple
f = "-"*5 * a                                       # f is the delimiter between bacons
d = ")===)" * a                                     # 2nd and 4th lines of bacon
print '\n'.join([f, d, "(===("*a, d, ''])*b + f     # Join everything together!


# Mathematica, 74 bytes

Array[b["-----",b=")===)","(===("][[#~Mod~4]]&,{4#2+1,#}]~Riffle~"\n"<>""&


Unnamed function taking two positive integer arguments and returning a string-with-newlines. A standard Mathematica approach: build a 2d array of strings using a (mod 4) chooser to cycle the strings in the vertical direction, then collapse them to a single string.

## Batch, 168 bytes

@set s=
@for /l %%i in (1,1,%1)do @call set s=%%s%%-___-
@set t=%s:_==%
@echo %s:_=-%
@for /l %%i in (1,1,%2)do @echo %t:-=)%&echo %t:-=(%&echo %t:-=)%&echo %s:_=-%


Rather unfortunately I can't write @echo %s:==-% otherwise that would eliminate the necessity for the second variable.

• Save 2 bytes by concatenating lines 1,2 and 3,4 with &... – Magoo Dec 31 '16 at 7:23

# C, 91 89 bytes

i;f(w,h){w=w*5+1;for(i=0;i<w*4*h+w;++i)putchar(i%w<w-1?i/w%4?i%w%5%4?61:40+i/w%2:45:10);}


# 05AB1E, 25 bytes

Code:

…)==û×Ð¬'(:s)¬g'-×=¸«»²F=


Explanation:

…)==û                         # Push the string ")===)"
×                        # String multiply by the first input
Ð                       # Triplicate the string
¬                      # Take the first character, which is a ')' and push
'(:                   # Replace by '('
s                  # Swap the top two elements
)                 # Wrap everything into an array
¬g               # Get the length of the first element in the array
'-×            # And repeat the character '-' that many times
=           # Print it without popping
¸«         # Append the string of dashes to the array
»        # Join by newlines
²F      # Second input times do...
=     #   Print the top of the stack without popping


Uses the CP-1252 encoding. Try it online!

# 05AB1E, 32 30 bytes

Saved 2 bytes thanks to Adnan.

'-5×…)==ûÐ')'(:s)vy¹×})I.D¬)˜»


Try it online!

Explanation

'-5×                            # push "-----"
…)==ûÐ                      # push 3 copies of ")===)"
')'(:s                # replace ")" with "(" in the 2nd copy
)               # wrap in list
vy¹×})         # repeat each list entry input-1 times
I.D      # repeat list input-2 times
¬     # push the first element of the list ("-----")
)˜   # wrap in list and flatten
»  # join by newline

• You can replace ")===)" by …)==û :) – Adnan Dec 31 '16 at 0:54
• @Adnan: Ah of course! Thanks! – Emigna Dec 31 '16 at 10:19

# Python 2, 70 bytes

def f(w,h):n=4*h+1;exec"n-=1;print'-)()-===-===-===-)()'[n%4::4]*w;"*n


Thanks to @xnor for saving 4 bytes!

Try it online!

• It looks like the lines don't alternate directions in your test case. – xnor Dec 31 '16 at 1:02
• It looks like a [_::3] would be shorter. – xnor Dec 31 '16 at 1:17
• Oh shoot, something went wrong there. Deleting until I can fix it. – Dennis Dec 31 '16 at 1:19
• That fixed my code without adding any bytes. Thanks! Let's see if I manage to deduplicate those lines again. – Dennis Dec 31 '16 at 1:34
• There's 2**n%5%3 which cycles [1, 2, 1, 0, 1, 2, 1, 0, ...]. Might that be useful? – xnor Dec 31 '16 at 3:06

## Python 2, 59 bytes

w,h=input()
for a in'-()('*h+'-':print(a+3*'=-'[a>')']+a)*w


Generates each line as a+b*3+a from the initial character a and the center character b (which is calculated from a). The a's cycle through '-()(', whereas b is '-' when a is '-', and '=' otherwise.

67 bytes:

w,h=input()
for a,b in['--']+zip(')()-','===-')*h:print(a+b*3+a)*w


Generates each line from its outer character a and center character b as a+b*3+a, then prints w copies of this. These cycle via a zip.

## JavaScript, 132129 121 bytes

-8 bytes thanks to @user2428118

(x,y)=>{a=b=["-----",")===)","(===(",")===)","-----"];for(i=0;++i<y;){b=[...b,...a.slice(1)]}return b.map(v=>v.repeat(x)).join(
)}


(x,y)=>eval('a=b=["-----",")===)","(===(",")===)","-----"];for(i=0;++i<y;)b=[...b,...a.slice(1)];b.map(v=>v.repeat(x)).join\n')


(x,y)=>eval('a=b=[c="-----",d=")===)","(===(",d,c];for(i=0;++i<y;)b=[...b,...a.slice(1)];b.map(v=>v.repeat(x)).join\n')


This can quite probably be golfed more. If you have a suggestion, please leave it in the comments.

• beat me by 1 byte.. :( – devRicher Dec 30 '16 at 18:23
• @devRicher But I haven't exactly golfed mine yet. :) – ericw31415 Dec 30 '16 at 18:39
• @devRicher Actually I accidentally miscounted the newline. Whoops. Edit: I've beat you now. – ericw31415 Dec 30 '16 at 18:44
• @ericw31415 (x,y)=>eval('a=b=[d="-----",c=")===)","(===(",c,d];for(i=0;++i<y;)b=[...b,...a.slice(1)].map(v=>v.repeat(x)).join_BACKTICK NEWLINE BACKTICK_;') – user2428118 Dec 30 '16 at 20:55
• @user2428118 This doesn't work? I can use your array simplification though. :) – ericw31415 Dec 31 '16 at 22:41

## Lua, 132 bytes

a="-----"b=")===)"c="(===("w,z=io.read(),io.read()function g(f)return f:rep(w).."\n"end print((g(a)..g(b)..g(c)..g(b)):rep(z)..g(a))


Long, literal string attempt. Try it here.

# JavaScript (ES6), 78

(x,y,r=s=>${s}.repeat(x)+ ,a=r)===),c=r-----)=>c+r(a+r(===(+a+c,x=y)  Test F= (x,y,r=s=>${s}.repeat(x)+
,a=r)===),c=r-----)=>c+r(a+r(===(+a+c,x=y)

function update() {
var x=+X.value,y=+Y.value
O.textContent=F(x,y)
}

update()
X<input type=number id=X value=1 min=1 oninput='update()'>
Y<input type=number id=Y value=1 min=1 oninput='update()'>
<pre id=O></pre>

# GameMaker Language, 160139148 bytes 133 bytes

x=argument0 y=argument1*4for(m=0;m<=y;m++){for(n=0;n<x;n++){a=")===)"if !m mod 4a="-----"else if n mod 2a="(===("r+=a}r+="#"}return r

• Also, before you suggest it, GML requires each part of the for loop to have a statement inside :( – Timtech Dec 30 '16 at 19:44

# Jelly, 26 bytes

4“\ḊƭVṠ’bị“-=()”s5ẋ€ḷẋµ1ịṭ


Try it online!

### How it works

4“\ḊƭVṠ’bị“-=()”s5ẋ€ḷẋµ1ịṭ  Main link. Left argument: w. Right argument: h

4                           Set the return value to 4.
“\ḊƭVṠ’b                   Yield 366323084456 and convert it to base 4.
This yields [1,1,1,1,1,0,2,2,2,0,3,2,2,2,3,0,2,2,2,0].
ị“-=()”            Index into that string, using modular 1-based indexing.
s5          Split the result into chunks of length 5.
ẋ€ḷ       Repeat the characters of each chunk w times.
ẋ      Repeat the array of chunks h times.
µ     Begin a new, monadic chain. Argument: M (bacon matrix)
1ị   Retrieve the first line.
ṭ  Tack; append it to M.


# C, 159158 153 bytes

p(s,n){printf(s,--n?p(s,n):0);}i,j;b(n,m){p("-----",n);for(j=3;j--;){p("\n",1);for(i=n;i--;)p(j%2?"(===(":")===)",1);}p("\n",1);--m?b(n,m):p("-----",n);}


Call with:

int main()
{
b(2,3);
}

• Nice to see another answer in C, but it can be done quite a bit shorter, see my answer :) – orlp Dec 30 '16 at 20:53

## C#, 160 bytes

x=>y=>{int i=0,h=4*y+1,j;var s=new string[h];for(;i<h;++i)if(i%4<1)s[i]=new string('-',x*5);else{var c=i%2>0?')':'(';for(j=0;j++<x;)s[i]+=c+"==="+c;}return s;};


Formatted version:

x => y =>
{
int i = 0, h = 4 * y + 1, j;

var s = new string[h];

for (; i < h; ++i)
if (i % 4 < 1)
s[i] = new string('-', x * 5);
else
{
var c = i % 2 > 0 ? ')' : '(';

for (j = 0; j++ < x; )
s[i] += c + "===" + c;
}

return s;
};


Try it online! (for some reason this link gives an error but works anyway)

## Dart, 125 117 bytes

(x,y){var t='-'*5*x,i=0;return()sync*{yield t;for(;i<y*4;i++)yield i%4>2?t:i%2>0?'(===('*x:')===)'*x;}().join('\n');}


Try it here!

# Dyalog APL, 55 bytes

This is my first time using Dyalog APL, so I'm sure this isn't the best approach.

 {(⊂'-----'),[1]⍉⍺(4×⍵)⍴')===)' '(===(' ')===)' '-----'}


Explanation: This is a quite simple approach, for a bacon grid of N×M, I make an N×(4M) matrix of the following four strings, repeating:

')===)'
'(===('
')===)'
'-----'


Then I concatenate the string ----- to the beginning.

Here's a quick explanation of the code:

')===)' '(===(' ')===)' '-----'  ⍝ An array of the four strings

⍺ (4×⍵) ⍴                        ⍝ reshape (⍴) the array to a matrix with the dimensions
⍝ ⍺ by (4×⍵) (⍺ is the 1st argument and ⍵ is the second)

⍉                               ⍝ transpose the matrix

,[1]                             ⍝ concatenate to beginning of the matrix...

(⊂'-----')                       ⍝ ...the string '-----' embedded in its own matrix (⊂)


# Tcl, 91 bytes

time {time {append h -----
append l )===)
append p (===(} $m puts "$h
$l$p
$l"}$n
puts $h  Try it online! • Do I need the put the input part? To account for the byte count? – sergiol Jan 4 '17 at 3:00 # PowerShell, 64 bytes param($x,$y)-split'----- )===) (===( )===) -----'*$y|gu|%{$_*$x}


Try it online!