67
\$\begingroup\$

...will you help me immortalize it?

enter image description here

I've had this pillow a few years now, and apparently it's time to get rid of it. Can you please write a function or program, that I can bring with me and use to recreate this pillow whenever I want to reminisce a bit.

It must work with no input arguments.

The output should look exactly like this (trailing newlines and spaces are OK).

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////

This is code golf, so the shortest code in bytes win!


Leaderboard

var QUESTION_ID=98701,OVERRIDE_USER=31516;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>

\$\endgroup\$
  • 7
    \$\begingroup\$ I'm somewhat disappointed that the pattern isn't a little more complex, to represent the different line thicknesses of the pillow. \$\endgroup\$ – Sparr Nov 6 '16 at 11:29
  • 4
    \$\begingroup\$ @Sparr I tried, but I didn't manage to make it look good using only ASCII characters. Figured this was close enough :) \$\endgroup\$ – Stewie Griffin Nov 6 '16 at 11:37
  • 3
    \$\begingroup\$ I'd have just added spaces \$\endgroup\$ – Sparr Nov 6 '16 at 20:37
  • 1
    \$\begingroup\$ 'apparently' :P \$\endgroup\$ – Pysis Nov 7 '16 at 19:01
  • 7
    \$\begingroup\$ Now you can buy a blank pillow and print the winner snippet on it. \$\endgroup\$ – coredump Nov 7 '16 at 19:46

65 Answers 65

3
\$\begingroup\$

PHP, 142 124 bytes

<?=str_replace(['#','-'],['/////','\\\\\\\\\\'],wordwrap(str_repeat(str_repeat("#-",24).str_repeat("-#",24), 4),12,"\n",1));

Previous version:

<?for($i=1;$i<4;$i++)echo wordwrap(str_repeat("/////\\\\\\\\\\",24),60,"\n",1)."\n".wordwrap(str_repeat("\\\\\\\\\\/////",24),60,"\n",1)."\n";

Output:

C:\PHP\>php this-is-my-pillow.php
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\$\endgroup\$
3
\$\begingroup\$

Canvas, 10 9 bytes

/54*╬6×3*

Try it here!

Explanation:

/          push "/"
 54*       extend horizontally 5 times and vertically 4 times
    ╬      quad-palindromize with 0 overlap
     6×    repeat horizontally 6 times
       3*  and again vertically, 3 times
\$\endgroup\$
2
\$\begingroup\$

SOML, 20 bytes (non-competing)

 /5* \5*+6*6{4{t}5{«

Explanation:

 /                    push "/", stack: ["/"]
  5*                  repeat it 5 times ["/////"]
     \                push "\" ["/////","\"]
      5*              repeat it 5 times ["/////","\\\\\"]
        +             add together ["/////\\\\\"]
         6*           repeat the string 6 times (it gets long here)
           6{         6 times repeat following code
             4{t}     output 4 times
                 5{«  put the 1st 5 chars at the end of the string

oops, forgot that I added the "t" function later today so non-competing

\$\endgroup\$
2
\$\begingroup\$

CJam, 24 23 bytes

"/\\"5e*6*]4*N*_W%]3*N*

ONLINE

Thanks 8478 (Martin Ender) for -1.

Explanation:

"/\\"5e*6*]4*N*_W%]3*N* Code
"/\\"                   Push "/\\"
     5                  Push 5
      e*                Repeat each
        6               Push 6
         *              Repeat
          ]             Wrap stack from [ to ToS in array
           4            Push 4
            *           Repeat
             N          Push N = "\n"
              *         Join
               _        Duplicate
                W       Push W = -1
                 %      Take every nth item
                  ]     Wrap stack from [ to ToS in array
                   3    Push 3
                    *   Repeat
                     N  Push N = "\n"
                      * Join
\$\endgroup\$
2
\$\begingroup\$

Vitsy, 28 26 bytes

This can be golfed a bit.

'\/'6\[4\[c\[4\[DO]r]aO]r]

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Pyth, 24 bytes

Jj*4[*6+*5\/*5\\;j*3[J_J

Try it!

Explanation:

Jj*4[*6+*5\/*5\\;j*3[J_J
   4                     4
      6                  6
         5               5
          \/             "/"
        *                Repeat
             5           5
              \\         "\\"
            *            Repeat
       +                 Concatenate
     *                   Repeat
    [                    List
  *                      Repeat
 j                       Join
J                        Assign copy to J
                ;        Close argument list
                   3     3
                     J   J
                       J J
                      _  Reverse
                    [    List
                  *      Repeat
                 j       Join
\$\endgroup\$
  • \$\begingroup\$ That explanation was painful to write... wish there was some way to use <something>5"/\\" instead of +*5\/*5\\. \$\endgroup\$ – Erik the Outgolfer Nov 6 '16 at 18:09
  • \$\begingroup\$ sC*5]"/\\" There is, but it's a byte longer. \$\endgroup\$ – Steven H. Nov 6 '16 at 18:21
  • \$\begingroup\$ I see I still have a fair bit to learn. I've only posted 2 Pyth answers but I hope I'm getting there. Any suggestions/comments as to how I could improve how I did it? Gratefully received if so :) \$\endgroup\$ – ElPedro Nov 6 '16 at 18:51
2
\$\begingroup\$

MATLAB, 58 44 bytes

Thanks to @Stewie Griffin for saving a bunch of bytes ;)

[repmat(kron(['/\';'\/'],ones(4,5)),3,6),'']

Old version:

p=@()char(47+45*kron(ones(3,6),kron([0 1;1 0],ones(4,5))))

\$\endgroup\$
2
\$\begingroup\$

Dyalog APL, 20 bytes

'/\'[4⌿5/2|+/¨⍳6 12] (requires ⎕IO=0)

\$\endgroup\$
2
\$\begingroup\$

Perl, 51 50 bytes

Perl 5.10.0+:

perl -E 'say+((@_=("/"x5,"\\"x5)x6,$/)x4,(pop@_,@_,$/)x4)x3'

Perl before 5.10.0 (52 bytes):

perl -e 'print+((@_=("/"x5,"\\"x5)x6,$/)x4,(pop@_,@_,$/)x4)x3'

Ungolfed:

say(
    (
        (
            @_ = ('/' x 5, '\\' x 5) x 6,
            $/,  # new line symbol
        ) x 4,
        (
            pop(@_),
            @_,
            $/,
        ) x 4,
    ) x 3
);

Thanx to @DomHastings for 1 byte.

\$\endgroup\$
  • 2
    \$\begingroup\$ Didn't think to use an array to store the slashes, nice! You can save 1 byte dropping the outermost () and prepend +: perl -E 'say+((@_=('/'x5,'\\'x5)x6,$/)x4,(pop@_,@_,$/)x4)x3' \$\endgroup\$ – Dom Hastings Nov 7 '16 at 12:45
1
\$\begingroup\$

C#, 126 Bytes

var s="";var c="/";for(int a=0;a<24;){for(int b=0;b<60;)s+=b++%5>0?c:c=="/"?c=@"\":c="/";s+="\n";c=a++%3>1?c=="/"?@"\":"/":c;}

string s is output. It could be 3 byte less, when it is infinite.

Ungolfed

        var s = "";
        var c = "/";
        for (int a = 0; a < 24;)
        {
            for (int b = 0; b < 60;)//write line
            {
                s += b++ % 5 > 0 ? c : c == "/" ? c = @"\" : c = "/";//Change  /to \ and vice versa after five times
            }
            s += "\n";


            c = a++ % 3 > 1 ? c == "/"? c = @"\" : c = "/" :c; //Change  /to \ and vice versa after three lines
        }
\$\endgroup\$
  • \$\begingroup\$ Can save at least two bytes with b%5>0 and c=a%3>1... I'm not sure because I'm on my phone but you may be able to store c as a char instead of a string and save a few bytes using implicit int to char conversions. Also do you really need all the c= in the last line ? I think it can be c=a%3>1?c=="/"?"\\":"/“:c; I see why you do it in the inner loop due to assigning to c and appending to s at the same time but you can probably refactor that a bit for byte savings as well \$\endgroup\$ – pinkfloydx33 Nov 6 '16 at 19:48
  • \$\begingroup\$ Maybe also take the post increments out of the loop and add them into into the assignments... Ie s+=b++%5... and c=a++%3... save another two bytes \$\endgroup\$ – pinkfloydx33 Nov 6 '16 at 19:52
  • \$\begingroup\$ Thank you, I complete forgot these c= in last line. Implicit int to char conversions does not work, because char is 16bit and written number is 32bit int, so there is only cast avaiable. \$\endgroup\$ – WerWet Nov 6 '16 at 20:52
1
\$\begingroup\$

GameMaker Language, 104 bytes

You should make sure that uninitialized variables don't throw an error. This setting is in the main page of Preferences. Otherwise, add e='' to the beginning of the program.

a="/////"b="\\\\\"d=b+a+b+a+b+a+b c=a+d d+=a for(i=0;i<24;i++)if i mod 8>3e+=d else e+=c e+="#" return e

P.S. Yes, each part of the for loop needs an expression. So I can't for(i=0;i<24;) and have i++ later.

Output

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\$\endgroup\$
  • \$\begingroup\$ Are there missing newlines? \$\endgroup\$ – u54112 Nov 6 '16 at 14:42
1
\$\begingroup\$

PowerShell v2+, 44 bytes

,(,('/////\\\\\'*6)*4+,('\\\\\/////'*6)*4)*3

Abuses the crap outta the default Write-Output behavior to put a newline between elements.

Explanation

I'm also trying out a new explanation format, rather than the long prose I traditionally write.

,(,('/////\\\\\'*6)*4+,('\\\\\/////'*6)*4)*3
    '/////\\\\\'*6                            # Repeat this string 6 times
  ,(              )*4                         # Repeat it into an array of four elements
                     +                        # Array concatenate with
                      ,('\\\\\/////'*6)*4)    # The same with the slashes the other way
,(                                       )*3  # Repeat it into an array of three elements
                                              # (i.e., 24 total strings)
\$\endgroup\$
1
\$\begingroup\$

Befunge-98, 76 bytes

'/\::2%0`!\4c*/2%0`!-> #0 #\ #\' $ #\_\3k:4k,1+:c%0`!> #0 #, #a_:cad+*\`!#@_

TryItOnline!

String processing/generation can be difficult with only a stack available...

A couple bytes may be able to be shaved off here or there, but I beat brainfuck, so I'm happy.

Explanation

Push '/' on the stack
Swap top two (at the beginning, zero will now be on top). Call top = iterator = n
Calculate (n % 2 == 0) != ((n / 48) % 2 == 0)
If true, swap top two, replace '/' with '\', swap again
Swap top two (so that we now have the character to print on top, followed by n)
Duplicate the char 4 times, and print 5 times
Increment n
If n % 12 == 0, print a newline character
If !(288 > n), end, else repeat
\$\endgroup\$
1
\$\begingroup\$

Pyth, 49 48 40 37 34 bytes

J60K*24+*5\/*5\\V24:*3+K_K*JN+J*JN

OK, I'm just learning Pyth so this is a direct port of my Python answer. Still a lot of golfing to do but it works so I am posting it anyway. Any hints gratefully received :)

1 byte saved with thanks to @Flp.Tkc

-8 by working out how to do it with a variable

-3 by moving the *24 to the assignment of K

-3 by getting rid of the quotes

\$\endgroup\$
  • 1
    \$\begingroup\$ I've never tried pyth apart from looking at the docs once or twice, but I think you can replace FN24 with V24 \$\endgroup\$ – FlipTack Nov 6 '16 at 12:37
  • \$\begingroup\$ Nice. Just tested and it works. Will check the docs on that. \$\endgroup\$ – ElPedro Nov 6 '16 at 12:39
1
\$\begingroup\$

Julia, 56 bytes

a="////\\\\\\\\"^6*"\n";print((a^4*a[[48:-1:1,49]]^4)^3)
\$\endgroup\$
1
\$\begingroup\$

C++ 138

void P(){int i,j,k,l;for(i=0;i<3;i++)for(j=0;j<8;j++)for(k=0;k<12;k++)for(l=0;l<5;l++)cout<<((j/4)?(k%2)?'/':'\\':(k%2)?'\\':'/')<<'\n';} 

Ungolfed

#include<conio.h>
#include<iostream>
using namespace std;

void P()
{
    int i,j,k,l;
    for(i=0;i<3;i++)
        for(j=0;j<8;j++)
            for(k=0;k<12;k++)
                for(l=0;l<5;l++)
                    cout<<((j/4)?(k%2)?'/':'\\':(k%2)?'\\':'/')<<'\n';
}

int main()
{
    P();
    _getch();
    return 0;
}
\$\endgroup\$
  • 1
    \$\begingroup\$ Why braces on the second for loop? \$\endgroup\$ – pinkfloydx33 Nov 6 '16 at 20:56
  • \$\begingroup\$ edited @pinkfloydx33 \$\endgroup\$ – Mukul Kumar Nov 9 '16 at 22:38
1
\$\begingroup\$

Lithp, 166 characters

Line split for readability.

#::((def x #S,N::(invoke S repeat N))(var A (x "/" 5))(var B (x "\\" 5))
(var C (+ (x (+ A B) 6) (nl)))(var D (+ (x (+ B A) 6) (nl)))
(print (x (+ (x C 4) (x D 4)) 5)))

Sample usage:

% pillow.lithp
(
    (def f #::((def x #S,N::(invoke S repeat N))(var A (x "/" 5))(var B (x "\\" 5))(var C (+ (x (+ A B) 6) (nl)))(var D (+ (x (+ B A) 6) (nl)))(print (x (+ (x C 4) (x D 4)) 5))))
    (f)
)

Run with:

./run.js pillow.lithp

This is a fairly simple solution that repeats characters. There is no standalone repeat function yet, so invoke is used to call "string".repeat(N) and adds a bit to the count.

\$\endgroup\$
1
\$\begingroup\$

Ruby, 83 + 14 = 97 bytes

puts Zlib.inflate Base64.decode64"eNrTB4EYECCdxTVENSP4pLOGqubhE8+j8Twaz6PxDAA3Pofw"

Add 14 bytes for -rzlib and -rbase64 flags.

\$\endgroup\$
1
\$\begingroup\$

R, 72 bytes

write(matrix(c(x<-rep(rep(c('/','\\'),e=5),24),rev(x)),24,60),'',60,,'')

builds a matrix of appropriate characters and writes it to stdout.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

T-SQL, 113 bytes

DECLARE @ INT=0L:IF @%8<4PRINT REPLICATE('/////\\\\\',6)ELSE PRINT REPLICATE('\\\\\/////',6)SET @+=1IF @<24GOTO L

Formatted:

DECLARE @ INT=0
L:
   IF @%8<4 PRINT REPLICATE('/////\\\\\',6)
   ELSE PRINT REPLICATE('\\\\\/////',6)
   SET @+=1
IF @<24 GOTO L

Using both string literals seems to be the shortest option, trying to REPLICATE(REPLICATE('/',5)+REPLICATE('\',5) is way longer, as is using additional variables.

\$\endgroup\$
1
\$\begingroup\$

SOGL V0.12, 11 bytes

└5*5∙╬¡6*3∙

Try it Here!

Explanation:

└            push "/"
 5*          repeat 5 times
   5∙        repeat vertically 5 times
     έ      quad-palindromize with 0 overlap and mirroring characters
       6*    multiply 6 times horizontally
         3∙  multiply 3 times vertically
\$\endgroup\$
1
\$\begingroup\$

Jstx, 21 bytes

♣/►\:►/;1BO♠/♦/!41o16

Not the shortest solution but I wanted to try this interesting challenge.

Explanation

♣  # Push literal 5
/  # Enter an iteration block over the first stack value.
►\ # Push literal \
:  # Push the sum of the second and first stack values.
►/ # Push literal /
;  # Push the difference of the second and first stack values.
1  # End an iteration block.
B  # Push five copies of the first stack value.
O  # Collapse all stack values into a string, then Push that string.
♠  # Push literal 6
/  # Enter an iteration block over the first stack value.
♦  # Push literal 4
/  # Enter an iteration block over the first stack value.
!  # Push a copy of the first stack value.
4  # Print the first stack value, then a newline.
1  # End an iteration block.
o  # Push the first stack value with characters in reverse order.
1  # End an iteration block.
6  # Ends program execution.

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Batch, 132 bytes

@set s=/////\\\\\
@set s=%s%%s%%s%%s%%s%%s%
@set s=%s% %s:~5%/////
@for %%s in (%s% %s% %s%)do @for /l %%i in (1,1,4)do @echo %%s

Works by building up the two types of row, then looping through six rows four times per row.

\$\endgroup\$
0
\$\begingroup\$

Racket 156 bytes

(define g #t)(for((k 24))(for((i 12))(for((j 5))(display(if g "/""\\")))(set! g(if g #f #t)))
(when(= 0(modulo(add1 k)4))(set! g(if g #f #t)))(displayln""))

Ungolfed:

(define(f)
  (define g #t)
  (for ((k 24))
    (for ((i 12))
      (for ((j 5))
        (display (if g "/" "\\")))
      (set! g (if g #f #t)))
    (when (= 0 (modulo (add1 k) 4))
      (set! g (if g #f #t)))
    (displayln "")))

Testing:

(f)

Output:

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\$\endgroup\$
0
\$\begingroup\$

Swift 3, 100 99 97 bytes

var a="/////",b="\\\\\\\\\\",c=""
(1...144).map{c+=a+b+($0%6<1 ?"\n":"")
$0%24<1 ?swap(&a,&b):()}

Could save 1 byte if Swift print function did not add a newline by default.

Edit 1:

Saved 1 byte by changing the if to ternary

if(i%24<1){swap(&a,&b)} -> i%24<1 ?swap(&a,&b):()

Edit 2:

Changed from for to map over the CountableClosedRange

\$\endgroup\$
0
\$\begingroup\$

Java 7, 148 bytes

String c(){String r,z,y=z=r="",p="/////\\\\\\\\\\",q="\\\\\\\\\\/////";int i=0;for(;i++<6;y+=p,z+=q);for(i=0;i<24;r+=(i++%8<4?y:z)+"\n");}return r;}

Ungolfed & test code:

Try it here.

class M{
  static String c() {
    String r, z, y = z = r = "",
           p = "/////\\\\\\\\\\",
           q = "\\\\\\\\\\/////";
    int i = 0;
    for(; i++ < 6; y += p, z += q);
    for(i = 0; i < 24; r += (i++%8 < 4 ? y : z)+"\n");
    return r;
  }

  public static void main(String[] a){
    System.out.println(c());
  }
}

Output:

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\$\endgroup\$
0
\$\begingroup\$

GolfSharp, 59 bytes

r(0,1440).s(n=>n%10<5^n%480<240?"\\":"/").j().S(60).j("\n")
\$\endgroup\$
0
\$\begingroup\$

PHP, 55 bytes

for(;$i<1440;)echo"/\\"[($i/5^$i/240)&1],"\n"[++$i%60];

toggles between forward and backward slash every 5 characters, inverted every 240 characters;
not counting newlines; newlines inserted every 60 characters.

has one trailing newline. Run with -r.


recursive program for 66 bytes:

<?="/\\"[($i/5^$i/240)&1]."\n"[++$i%60];if($i<1440)include"p.php";

save to file p.php; call from CLI (or insert ($i?"":"<pre>"). after <?=)

\$\endgroup\$
0
\$\begingroup\$

APL, 16

4⌿5/1↓⍉12 7⍴'\/'

Try it on tryapl.org

\$\endgroup\$
0
\$\begingroup\$

Python 3, 60 bytes

Lots of multiplying strings!

print((((('/'*5+'\\'*5)*6+'\n')*4)+(('\\'*5+'/'*5)*6+'\n')*4)*3)

Output

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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