The Saltine Challenge

23

4

Here is an ASCII saltine cracker:

 _________________
|  .     .     .  |
|     .     .     |
|  .     .     .  |
|     .     .     |
|  .     .     .  |
|_________________|

Here are two crackers stacked:

 _________________
|  .     .     .  |
|     . __________|______
|  .   |  .     .     .  |
|     .|     .     .     |
|  .   |  .     .     .  |
|______|     .     .     |
       |  .     .     .  |
       |_________________|

Write the shortest program possible that takes a positive integer and draws a stack of that many ASCII saltine crackers.

Input may come from stdin, command line, or you may simply write a function. The input will always be valid. Output must go to stdout or closest alternative.

Each stacked cracker is always shifted 2 characters down and 7 characters right of the cracker below it. There should be no trailing spaces or extraneous newlines.

The shortest program in bytes wins.

Examples

If the input is 1 the output is

 _________________
|  .     .     .  |
|     .     .     |
|  .     .     .  |
|     .     .     |
|  .     .     .  |
|_________________|

If the input is 2 the output is

 _________________
|  .     .     .  |
|     . __________|______
|  .   |  .     .     .  |
|     .|     .     .     |
|  .   |  .     .     .  |
|______|     .     .     |
       |  .     .     .  |
       |_________________|

If the input is 3 the output is

 _________________
|  .     .     .  |
|     . __________|______
|  .   |  .     .     .  |
|     .|     . __________|______
|  .   |  .   |  .     .     .  |
|______|     .|     .     .     |
       |  .   |  .     .     .  |
       |______|     .     .     |
              |  .     .     .  |
              |_________________|

And so on.

the real saltine challenge

Calvin's Hobbies

Posted 2014-10-06T15:16:59.847

Reputation: 84 000

1How does the outline of the cracker below overrides the outline of the one above it? – proud haskeller – 2014-10-06T15:42:23.813

For 0, should the program cleanly exit with no output? Or do we not have to handle 0? – Claudiu – 2014-10-06T15:49:29.383

@proudhaskeller The cracker pattern extends as you would expect from the examples. What about the border is unclear? – Calvin's Hobbies – 2014-10-06T15:53:46.853

1@Calvin'sHobbies: I think he's questioning why the top border of the stacked crackers is ___|___ instead of _______. I'm guessing it would look weird if it were the latter – Claudiu – 2014-10-06T15:54:40.933

2@Claudiu Oh. Yeah, it's not perfect but it looks weirder the other way. – Calvin's Hobbies – 2014-10-06T15:55:49.627

6@Calvin'sHobbies In fact, I think that single character is the most interesting part of this challenge. ^^ – Martin Ender – 2014-10-06T16:05:38.203

3Passing 0 should segfault. – Naftuli Kay – 2014-10-06T21:37:30.030

Answers

4

CJam, 140 125 119 116 bytes

li__7*C+S*a\2*5+*\{5m>S'|6*+_" ."5*5/{'__@\++}:U%3*0@t{S5*U_}%\a+zsB'|tJ/{\(J>@\+a+}/{7m<}%}*{Cm<0{;)_' =}g+}%N*B'_t

Try it online.

A single saltine

The code snippet

S'|6*+_      " Push ' ||||||' twice.                                                      ";
" ."5*5/     " Push [' . . ' '. . .'].                                                    ";
{'__@\++}:U% " Prepend and append an underscore to each string in the previous array.     ";
3*           " Repeat the resulting array thrice.                                         ";
0@t          " Replace its first element with ' ||||||'.                                  ";
{S5*U_}%     " Insert '_     _' after each element of the array.                          ";
\a+          " Append ' ||||||' to the array.                                             ";
z            " Zip; transpose rows with columns.                                          ";
sB'\t        " Flatten the array of strings and replace the 12th element with a '|'.      ";
19/          " Split into chunks of length 19.                                            ";

leaves the following on the stack:

[
  " __________|______ "
  "|  .     .     .  |"
  "|     .     .     |"
  "|  .     .     .  |"
  "|     .     .     |"
  "|  .     .     .  |"
  "|_________________|"
]

Stacked saltines

Assume the saltine from above is saved in Z.

li               " I := int(input())                                                      ";
__7*C+S*a\2*5+*  " R:= [(I * 7 + 12) * ' '] * (I * 2 + 5)                                 ";
\{               " Repeat I times:                                                        ";
  5m>            "   R := R[-5:] + R[:-5]                                                 ";
  Z              "   Push a single saltine, as an array of lines.                         ";
  {              "   For each line L of the saltine:                                      ";
    \(J>@\+a+    "     R := R[1:] + [R[0][19:] +     L]                                   ";
  }/             "                                                                        ";
  {7m<}%         "   R := [ L[7:] + L[:7] : L in R ]                                      ";
}*               "                                                                        ";
{                " R := [                                                                 ";
  Cm<            "   (L[12:] + L[:12])                                                    ";
  0{;)_' =}g+    "                    .rstrip()                                           ";
}%               " : L in R ]                                                             ";
N*               " R := '\n'.join(R)                                                      ";
B'_t             " R[11] := '|'                                                           ";

Dennis

Posted 2014-10-06T15:16:59.847

Reputation: 196 637

11

JavaScript (E6) 249 259 289 304 345

Not so confident about the string compression. Found a good compression for the strings. The simple 1 cracker case seems difficult to manage. There may be a better way...

F=n=>{
  for(B=",|4.,|1.2,|1.4.4.1|,|5,|4.4.4|, 9|5, 87 ,|87|".replace(/\d/g,c=>' _'[c>4|0][R='repeat'](-~c)).split(','),
  O=(c,b=0,a=0)=>console.log(' '[R](y)+B[a]+B[b][R](x)+B[c]),
  r=x=y=0,
  O(7);
  O(3,2),
  !(z=++r>2)|x;)
    x+=(v=r<n)-z,O(v+5,1,z*4),y+=z*7;
  O(8)
}

Ungolfed more or less

That is the basic code, before I started golfing. It's not exactly the same and works only for n > 2

F=n=>{
  O=t=>console.log(t)

  r=0
  x=0
  y=0

  O(' _________________')
  O(' '.repeat(y)+'|  .   '.repeat(x)+'|  .     .     .  |')

  while (++r<n)
  {
    x++;
    if (r>2)
    {
       x--;
       O(' '.repeat(y)+'|______'+'|     .'.repeat(x)+' __________|______')
       y+=7;
       O(' '.repeat(y)+'|  .   '.repeat(x)+'|     .     .     |')
    }
    else
    {
       O(' '.repeat(y)+'|     .'.repeat(x)+' __________|______')
       O(' '.repeat(y)+'|  .   '.repeat(x)+'|  .     .     .  |')
    }

  }  
  while(x--)
  {
     O(' '.repeat(y)+'|______'+'|     .'.repeat(x)+'|  .     .     .  |')
     y+=7;
     O(' '.repeat(y)+'|  .   '.repeat(x)+'|     .     .     |')
  }

  O(' '.repeat(y)+'|_________________|')
}

Test In FireFox/FireBug console

F(4)

Output

 _________________
|  .     .     .  |
|     . __________|______
|  .   |  .     .     .  |
|     .|     . __________|______
|  .   |  .   |  .     .     .  |
|______|     .|     . __________|______
       |  .   |  .   |  .     .     .  |
       |______|     .|     .     .     |
              |  .   |  .     .     .  |
              |______|     .     .     |
                     |  .     .     .  |
                     |_________________|

edc65

Posted 2014-10-06T15:16:59.847

Reputation: 31 086

8

Python, 252 241 characters

s="eJxTiIeDGgiloBBRo6CgpwACcLIGJKaAKlxDmbp4dFADAL+oIFI=".decode('base64').decode('zip').split('X')
N=input()
R=range
G=map(list,[' '*(7*N+12)]*(2*N+5))
for n in R(N):
 for y in R(7):G[2*n+y][7*n:]=s[y]
G[0][11]='_'
for g in G:print''.join(g)

Thanks to FryAmTheEggman and Vincent for snipping off 11 characters.

A preponderance of crackers:

$ echo 17 | python saltines.py
 _________________
|  .     .     .  |
|     . __________|______
|  .   |  .     .     .  |
|     .|     . __________|______
|  .   |  .   |  .     .     .  |
|______|     .|     . __________|______
       |  .   |  .   |  .     .     .  |
       |______|     .|     . __________|______
              |  .   |  .   |  .     .     .  |
              |______|     .|     . __________|______
                     |  .   |  .   |  .     .     .  |
                     |______|     .|     . __________|______
                            |  .   |  .   |  .     .     .  |
                            |______|     .|     . __________|______
                                   |  .   |  .   |  .     .     .  |
                                   |______|     .|     . __________|______
                                          |  .   |  .   |  .     .     .  |
                                          |______|     .|     . __________|______
                                                 |  .   |  .   |  .     .     .  |
                                                 |______|     .|     . __________|______
                                                        |  .   |  .   |  .     .     .  |
                                                        |______|     .|     . __________|______
                                                               |  .   |  .   |  .     .     .  |
                                                               |______|     .|     . __________|______
                                                                      |  .   |  .   |  .     .     .  |
                                                                      |______|     .|     . __________|______
                                                                             |  .   |  .   |  .     .     .  |
                                                                             |______|     .|     . __________|______
                                                                                    |  .   |  .   |  .     .     .  |
                                                                                    |______|     .|     . __________|______
                                                                                           |  .   |  .   |  .     .     .  |
                                                                                           |______|     .|     . __________|______
                                                                                                  |  .   |  .   |  .     .     .  |
                                                                                                  |______|     .|     .     .     |
                                                                                                         |  .   |  .     .     .  |
                                                                                                         |______|     .     .     |
                                                                                                                |  .     .     .  |
                                                                                                                |_________________|

This code seems really inefficient, but other answers will tell. It just copies and pastes the saltine cracker into an array at the right spot, accounts for the bottom-most cracker being 1-character off, then prints it all.

I can get it down to 230 characters if I use an external file (202 code + 38 file size + 1 file name).

Claudiu

Posted 2014-10-06T15:16:59.847

Reputation: 3 870

11Please show every output for n=1 upto 2^10 so we can be sure that your program really does the right thing. – flawr – 2014-10-06T16:52:13.400

list(' '*(7*N+12)) could be [' ']*(7*N+12). – FryAmTheEggman – 2014-10-06T17:48:54.653

1@flawr: Sir, is that to say - are you say - are you, ah, alluding to - insinuating or perhaps just suggesting, that I was being silly? – Claudiu – 2014-10-06T20:30:36.187

1@Claudiu I can assure that I would not even dare to think of insinuating you of an act that would even only have an impalable touch of sillynes. =P – flawr – 2014-10-07T11:30:46.930

I'm pretty sure you can replace G[2*n+y][7*n:7*n+19] with G[2*n+y][7*n:] – Vincent – 2014-10-07T14:25:27.870

1And G=[list(' '*(7*N+12))for _ in R(2*N+5)] with G=map(list,[' '*(7*N+12)]*(2*N+5)) – Vincent – 2014-10-07T14:35:41.467

7

Perl 189

Stealing some string compression ideas from choroba, I got it down to:

echo 4 | perl -E 's/\d/($&<8?$":_)x$&/ge for@l=("|2.5.5.2|"," 98","|5.5.5|","|98|",7)[102020344=~/./g];map{say for@l[0,1];$l[$_]=substr($l[$_+2],0,7).$l[$_]for 0..6;substr$l[0],-7,1,"|"}2..<>;say for@l[0..6]'

For easier viewing in your browser:

s/\d/($&<8?$":_)x$&/ge for@l=
("|2.5.5.2|"," 98","|5.5.5|","|98|",7)[102020344=~/./g];map{
    say for@l[0,1];
    $l[$_]=substr($l[$_+2],0,7).$l[$_]for 0..6;
    substr$l[0],-7,1,"|"
}2..<>;say for@l[0..6]

For context, my best before that:

Perl 207

$u='_'x11;s/:/ .  /g,s/.(.)/$&$1/g,$_.=$/for@l=("|:: . |"," $u","|  :: |","|$u|",$"x5)[102020344=~/./g];map{print@l[0,1];$l[$_]=substr($l[$_+2],0,7).$l[$_]for 0..6;substr$l[0],-8,1,'|'}2..pop;print@l[0..6]

Adding newlines and indentation for ease of reading in your browser:

$u="_"x11;
s/:/ .  /g,s/.(.)/$&$1/g,$_.=$/for@l=
("|:: . |"," $u","|  :: |","|$u|",$"x5)[102020344=~/./g];
map{
    print@l[0,1];
    $l[$_]=substr($l[$_+2],0,7).$l[$_]for 0..6;
    substr$l[0],-8,1,"|"
}2..pop;
print@l[0..6]

You can replace "pop" with "<>" to take the count from STDIN instead of as a command-line parameter and get to 206 bytes. Going to STDERR would drop it to 204 bytes.

If I could enable the 'say' feature without a byte penalty, then I could get to 202.

$u="_"x11;s/:/ .  /g,s/.(.)/$&$1/g for@l=("|:: . |"," $u","|  :: |","|$u|",$"x5)[102020344=~/./g];map{say for@l[0,1];$l[$_]=substr($l[$_+2],0,7).$l[$_]for 0..6;substr$l[0],-7,1,"|"}2..<>;say for@l[0..6]

invoked as:

echo 4 | perl -E '$u="_"x11;s/:/ .  /g,s/.(.)/$&$1/g for@l=("|:: . |"," $u","|  :: |","|$u|",$"x5)[102020344=~/./g];map{say for@l[0,1];$l[$_]=substr($l[$_+2],0,7).$l[$_]for 0..6;substr$l[0],-7,1,"|"}2..<>;say for@l[0..6]'

Tye

Posted 2014-10-06T15:16:59.847

Reputation: 71

You are allowed to enable say without a penalty because it is the same as running on the command line with -E instead of -e. perl -E'' doesn't count toward your total characters. – hmatt1 – 2014-10-08T19:16:22.533

Your output is incorrect. Check the _|_. – choroba – 2014-10-09T14:46:22.953

@choroba, thanks! I forgot to put that substr back in after trying to replace it with y/|/_/ (but always ending up with longer code). From 168 to 189. – Tye – 2014-10-09T15:01:12.133

4

Perl 201

(remove newlines except the first one to get the #)

$_=" 46|6
15.5.5|15.5.5|198|";
s/1/|  .5.5.  ||/g;
s/\d/(5^$&?_:$")x$&/ge;
@o=@l=/.{18}.?/g;
map{
$s=$_*7;
substr$o[$_-5],$s,12,$l[$_]for 0..4;
push@o,($"x$s).$l[$_]for 5,6
}1..-1+pop;
$o[$,=$/]=~y/|/_/;
print@o

say + <> = 198.

choroba

Posted 2014-10-06T15:16:59.847

Reputation: 161

"There should be no trailing spaces" – Tye – 2014-10-09T13:08:43.490

@Tye: OK, back to 202 :-( – choroba – 2014-10-09T13:24:04.730

2

Haskell, 215 bytes

This one builds up the cracker stack inductively, pulling cracker parts and spacing out of a couple of cyclic lists:

(b:u:i)=" _|"
(%)=replicate
z=5%b++'.':z
m!n=i++map(z!!)[m..n]
s=7%b:s
d=3!19++i
e=0!16++i
y=i++6%u
g 1=[e,d,e,d,i++17%u++i]
g k=zipWith(++)(0!5:3!8:0!5:3!8:y:s)$(b:10%u++y):d:g(k-1)
f k=mapM putStrLn$(b:17%u):d:g k

The control flow is pretty straightforward; most of the trickery is in reusing as much of the cracker parts as possible.

Ungolfed:

top     = " _________________"
top'    = " __________|______"
dots3   = "|  .     .     .  |"
dots2   = "|     .     .     |"
bot     = "|_________________|"

halfR   = "|     ."
halfL   = "|  .   "
halfBot = "|______"

spacer  = "       "
spaces = repeat spacer

saltine = above ++ [dots2, dots3, dots2, dots3, bot]
above   = [top, dots3]
left    = [halfR, halfL, halfR, halfL, halfBot] ++ spaces

another (oldTop:oldCracker) = above ++ zipWith (++) left (top' : oldCracker)

crackers 1 = saltine
crackers k = another $ crackers (k - 1)

test = putStr . unlines . crackers

Matt Noonan

Posted 2014-10-06T15:16:59.847

Reputation: 1 014

1

Python, 299

I thought I was being clever but the solution turned out to be overly complicated and longer than any straight forward approach, yet I couldn't resist to post it. The program explicitly calculates which character has to be plotted at the different positions of the output string, without looping over the individual crackers.

N=input()
m,n,c,r=12+7*N,5+2*N,3.5,range
print''.join(i>m-2and'\n'or(i%7<(i/c<j<7+i/c)*(i<N*7)or(i+4)%7<(i/c<j+4<2+4*(i>m-3)+i/c)*(i>16))and'|'or j%2<(j*c<i<17+j*c)*(j<n-5)+(j*c<i+22<8+10*(j>n-3)+j*c)*(j>5)and'_'or(i-j*3-min(i/7,~-j/2,N-1)+1)%6<(-3<-~i/7-j/2<3)and'.'or' 'for j in r(n)for i in r(m))

And the last line expanded to see what's going on:

print ''.join(
              '\n' if i>m-2 else
              '|' if i%7<(i/c<j<7+i/c)*(i<N*7) or (i+4)%7<(i/c<j+4<2+4*(i>m-3)+i/c)*(i>16) else
              '_' if j%2<(j*c<i<17+j*c)*(j<n-5)+(j*c<i+22<8+10*(j>n-3)+j*c)*(j>5) else
              '.' if (i-j*3-min(i/7,~-j/2,N-1)+1)%6<(-3<-~i/7-j/2<3) else
              ' '
              for j in r(n)
              for i in r(m)
             )

Emil

Posted 2014-10-06T15:16:59.847

Reputation: 1 438

1

C,284

For the function f and the #defines, excluding unnecessary whitespace and main. In accordance with edc65's comment, I have included a 128-bit integer type (which I was going to do anyway) but I miscalculated again and I can only do 29 crackers before the tops start going missing.

Complete function and test program below. Will comment it later.

#define C b,b,c,b,b
#define S s[i/v*7-i%v
f(n){
  __int128 a=4095,b=a+2,c=6281,d=4641,w=998,v=19,s[998]={a,C,d,C,d,C,a},i=v;
  for(;i<n*v;i++)S+18]|=S+11]*16&-1<<(12+i/v*2-i%v/18)*(i%v>7); 
  for(i=(5+n*2)*w;i--;i%w||puts(""))i%w>i/w/2*7-21+i/w%2*6&&s[i%w]&&putchar(" _.|"[(s[i%w]>>i/w*2)&3]);
}


main(){
  int m;
  scanf("%d",&m);f(m);
}

There are only four different characters in the output. These are decoded from binary numbers 0-3 by " _.|". The array s[] contains an integer for each column of the output, 2 bits per symbol, which is intitialised to contain the rightmost cracker.

The first for loop copies the previous cracker, leftshifts it to move it up, deletes the bottom right corner using & and ORs it with the previous cracker, 7 steps to the left.

The second for loop decodes the 2-bit representation of each character into the actual character and prints the character. There's a lot of code here just to suppress unnecesary whitespace in the output. I'm disappointed that my score went up instead of down from my previous revision.

Output

That's 29 crackers. I replaced the space with a - for a different look, and to show that no trailing spaces or extraneous newlines in the output.

-_________________
|--.-----.-----.--|
|-----.-__________|______
|--.---|--.-----.-----.--|
|-----.|-----.-__________|______
|--.---|--.---|--.-----.-----.--|
|______|-----.|-----.-__________|______
-------|--.---|--.---|--.-----.-----.--|
-------|______|-----.|-----.-__________|______
--------------|--.---|--.---|--.-----.-----.--|
--------------|______|-----.|-----.-__________|______
---------------------|--.---|--.---|--.-----.-----.--|
---------------------|______|-----.|-----.-__________|______
----------------------------|--.---|--.---|--.-----.-----.--|
----------------------------|______|-----.|-----.-__________|______
-----------------------------------|--.---|--.---|--.-----.-----.--|
-----------------------------------|______|-----.|-----.-__________|______
------------------------------------------|--.---|--.---|--.-----.-----.--|
------------------------------------------|______|-----.|-----.-__________|______
-------------------------------------------------|--.---|--.---|--.-----.-----.--|
-------------------------------------------------|______|-----.|-----.-__________|______
--------------------------------------------------------|--.---|--.---|--.-----.-----.--|
--------------------------------------------------------|______|-----.|-----.-__________|______
---------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
---------------------------------------------------------------|______|-----.|-----.-__________|______
----------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
----------------------------------------------------------------------|______|-----.|-----.-__________|______
-----------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
-----------------------------------------------------------------------------|______|-----.|-----.-__________|______
------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
-------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
-------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
--------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
--------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
---------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
---------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
----------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
----------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
-----------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
-----------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
-------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
-------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
--------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
--------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
---------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
---------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
----------------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
----------------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
-----------------------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
-----------------------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-----.-----|
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.-----.-----.--|
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.-----.-----|
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--.-----.-----.--|
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|_________________|

Level River St

Posted 2014-10-06T15:16:59.847

Reputation: 22 049

There was no max value in the question, just "a positive integer". So 1 to 5 is your idea of any positive integer? – edc65 – 2014-10-10T15:26:17.913

@edc65 For a few more bytes you can have a 128-bit integer type instead of 32 bits. That will take it up to 56 crackers, which should be enough (that's over 20kb of output). I admit I miscalculated the number of crackers I could get with a 32-bit integer when I started, I thought it was at least ten. But yes, all programs will have some kind of upper limit on the number of crackers they can produce and it is up to the OP to decide what that is. It should be specified in the question. As it is I will accept the OP's ruling on the validity of my answer (which isn't finished.) – Level River St – 2014-10-10T19:56:15.707

0

JavaScript (ES6) HTML5 - 233 236 bytes

Probably not a valid answer, but I just couldn't resist posting, sorry :-P

F=n=>{d="______";b="\n|  .     .     .  |";a=b+"\n|     .     .     |";for(i=0;i<n;)document.body.innerHTML+="<pre style='background:#fff;position:fixed;top:"+i*28+"px;left:"+i*56+"px'> ____"+d+'|_'[+!i++]+d+a+a+b+"\n|"+d+d+"_____|"}

Test in Firefox with F(1), F(2), F(3), etc.

Example: http://jsfiddle.net/Lvmg9fe8/7/

me and my cat

Posted 2014-10-06T15:16:59.847

Reputation: 1 107

I don't know JavaScript, but this Fiddle doesn't appear to do anything (whereas I've been able to run other Fiddles no problem.) I have Google Chrome and Internet Explorer. – Level River St – 2014-10-07T22:28:24.773

@steveverrill it works only in Firefox, like almost everything that's sold as JavaScript here. Chrome and IE don't support EcmaScript 6. – me and my cat – 2014-10-07T22:43:18.277

It works (in Firefox), though it's not quite what I'm looking for ;) – Calvin's Hobbies – 2014-10-07T23:15:30.770

I can't seem to get this to work either... I'm receiving an "undefined" response whenever I enter F(1) or any other number, after having entered this code in JS console in Firefox... – WallyWest – 2014-11-18T22:08:42.837