24
\$\begingroup\$

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

\$\endgroup\$
7
  • 1
    \$\begingroup\$ How does the outline of the cracker below overrides the outline of the one above it? \$\endgroup\$ Commented Oct 6, 2014 at 15:42
  • 1
    \$\begingroup\$ @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 \$\endgroup\$
    – Claudiu
    Commented Oct 6, 2014 at 15:54
  • 2
    \$\begingroup\$ @Claudiu Oh. Yeah, it's not perfect but it looks weirder the other way. \$\endgroup\$ Commented Oct 6, 2014 at 15:55
  • 7
    \$\begingroup\$ @Calvin'sHobbies In fact, I think that single character is the most interesting part of this challenge. ^^ \$\endgroup\$ Commented Oct 6, 2014 at 16:05
  • 3
    \$\begingroup\$ Passing 0 should segfault. \$\endgroup\$ Commented Oct 6, 2014 at 21:37

10 Answers 10

11
\$\begingroup\$

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

 _________________
|  .     .     .  |
|     . __________|______
|  .   |  .     .     .  |
|     .|     . __________|______
|  .   |  .   |  .     .     .  |
|______|     .|     . __________|______
       |  .   |  .   |  .     .     .  |
       |______|     .|     .     .     |
              |  .   |  .     .     .  |
              |______|     .     .     |
                     |  .     .     .  |
                     |_________________|
\$\endgroup\$
8
\$\begingroup\$

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

\$\endgroup\$
6
  • 11
    \$\begingroup\$ Please show every output for n=1 upto 2^10 so we can be sure that your program really does the right thing. \$\endgroup\$
    – flawr
    Commented Oct 6, 2014 at 16:52
  • \$\begingroup\$ list(' '*(7*N+12)) could be [' ']*(7*N+12). \$\endgroup\$ Commented Oct 6, 2014 at 17:48
  • 1
    \$\begingroup\$ @flawr: Sir, is that to say - are you say - are you, ah, alluding to - insinuating or perhaps just suggesting, that I was being silly? \$\endgroup\$
    – Claudiu
    Commented Oct 6, 2014 at 20:30
  • 1
    \$\begingroup\$ @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 \$\endgroup\$
    – flawr
    Commented Oct 7, 2014 at 11:30
  • 1
    \$\begingroup\$ And G=[list(' '*(7*N+12))for _ in R(2*N+5)] with G=map(list,[' '*(7*N+12)]*(2*N+5)) \$\endgroup\$
    – Vincent
    Commented Oct 7, 2014 at 14:35
7
\$\begingroup\$

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]'
\$\endgroup\$
3
  • \$\begingroup\$ 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. \$\endgroup\$
    – hmatt1
    Commented Oct 8, 2014 at 19:16
  • \$\begingroup\$ Your output is incorrect. Check the _|_. \$\endgroup\$
    – choroba
    Commented Oct 9, 2014 at 14:46
  • \$\begingroup\$ @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. \$\endgroup\$
    – Tye
    Commented Oct 9, 2014 at 15:01
4
\$\begingroup\$

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] := '|'                                                           ";
\$\endgroup\$
0
4
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ "There should be no trailing spaces" \$\endgroup\$
    – Tye
    Commented Oct 9, 2014 at 13:08
  • \$\begingroup\$ @Tye: OK, back to 202 :-( \$\endgroup\$
    – choroba
    Commented Oct 9, 2014 at 13:24
2
\$\begingroup\$

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
\$\endgroup\$
1
\$\begingroup\$

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)
             )
\$\endgroup\$
1
\$\begingroup\$

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.

-_________________
|--.-----.-----.--|
|-----.-__________|______
|--.---|--.-----.-----.--|
|-----.|-----.-__________|______
|--.---|--.---|--.-----.-----.--|
|______|-----.|-----.-__________|______
-------|--.---|--.---|--.-----.-----.--|
-------|______|-----.|-----.-__________|______
--------------|--.---|--.---|--.-----.-----.--|
--------------|______|-----.|-----.-__________|______
---------------------|--.---|--.---|--.-----.-----.--|
---------------------|______|-----.|-----.-__________|______
----------------------------|--.---|--.---|--.-----.-----.--|
----------------------------|______|-----.|-----.-__________|______
-----------------------------------|--.---|--.---|--.-----.-----.--|
-----------------------------------|______|-----.|-----.-__________|______
------------------------------------------|--.---|--.---|--.-----.-----.--|
------------------------------------------|______|-----.|-----.-__________|______
-------------------------------------------------|--.---|--.---|--.-----.-----.--|
-------------------------------------------------|______|-----.|-----.-__________|______
--------------------------------------------------------|--.---|--.---|--.-----.-----.--|
--------------------------------------------------------|______|-----.|-----.-__________|______
---------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
---------------------------------------------------------------|______|-----.|-----.-__________|______
----------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
----------------------------------------------------------------------|______|-----.|-----.-__________|______
-----------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
-----------------------------------------------------------------------------|______|-----.|-----.-__________|______
------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
-------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
-------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
--------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
--------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
---------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
---------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
----------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
----------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
-----------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
-----------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
-------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
-------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
--------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
--------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
---------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
---------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
----------------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
----------------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
-----------------------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
-----------------------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-__________|______
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.---|--.-----.-----.--|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.|-----.-----.-----|
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--.---|--.-----.-----.--|
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|______|-----.-----.-----|
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--.-----.-----.--|
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|_________________|
\$\endgroup\$
2
  • \$\begingroup\$ There was no max value in the question, just "a positive integer". So 1 to 5 is your idea of any positive integer? \$\endgroup\$
    – edc65
    Commented Oct 10, 2014 at 15:26
  • \$\begingroup\$ @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.) \$\endgroup\$ Commented Oct 10, 2014 at 19:56
0
\$\begingroup\$

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/

\$\endgroup\$
4
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Oct 7, 2014 at 22:28
  • \$\begingroup\$ @steveverrill it works only in Firefox, like almost everything that's sold as JavaScript here. Chrome and IE don't support EcmaScript 6. \$\endgroup\$ Commented Oct 7, 2014 at 22:43
  • \$\begingroup\$ It works (in Firefox), though it's not quite what I'm looking for ;) \$\endgroup\$ Commented Oct 7, 2014 at 23:15
  • \$\begingroup\$ 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... \$\endgroup\$ Commented Nov 18, 2014 at 22:08
0
\$\begingroup\$

Canvas, 54 bytes

H┐“)4╪xω╷┘IQ+azQ┴¾4*↔⌐∔v│↶++z2;e\1p9H+m}`1L²‟19┤n;83╋╋

Try it here!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.