74
\$\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
  • 10
    \$\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
    Commented Nov 6, 2016 at 11:29
  • 5
    \$\begingroup\$ @Sparr I tried, but I didn't manage to make it look good using only ASCII characters. Figured this was close enough :) \$\endgroup\$ Commented Nov 6, 2016 at 11:37
  • 4
    \$\begingroup\$ I'd have just added spaces \$\endgroup\$
    – Sparr
    Commented Nov 6, 2016 at 20:37
  • 2
    \$\begingroup\$ 'apparently' :P \$\endgroup\$
    – Pysis
    Commented Nov 7, 2016 at 19:01
  • 11
    \$\begingroup\$ Now you can buy a blank pillow and print the winner snippet on it. \$\endgroup\$
    – coredump
    Commented Nov 7, 2016 at 19:46

75 Answers 75

3
\$\begingroup\$

Vim, 44 27 bytes

EDIT Lot of bytes won thanks to @DrMcMoylex:

5i\<esc>5a/<esc>0y$5PY4P5x$pY3PyGPP

Original answer:

I'm not sure that really fits the rules of this site but I thought that was fun to try it:

i\<esc>59.:s;\v(.{5})\1;\1/////;g<CR>Y4P5x$pY3PyGPP

Which can be decomposed like this:

i\<esc>                       Insert a \
59.                           Repeat 59 time the insertion
:s;\v(.{5})\1;\1/////;g<CR>   Match 5 characters followed by the same 5 characters
                              And replace them by these 5 characters followed by 5 /
Y4P                           Copy the line and repeat it 4 times
5x$p                          On the current line delete 5 characters and put them 
                              at the end of the line
Y3P                           Copy the line and repeat it 3 times
yG                            Copy all the lines
PP                            Repeat them 2 times
\$\endgroup\$
3
  • \$\begingroup\$ Oh hey statox, welcome to the site! This totally fits the rules. I golf mostly in vim. Just so you know, you could do 5i/<esc>5a\<esc>0y$5P at the start to save 9 bytes. \$\endgroup\$
    – DJMcMayhem
    Commented Nov 7, 2016 at 20:16
  • \$\begingroup\$ Hey DrMcMoylex (new name? :-) ) glad to see you here and that my answer fits. Also thanks for your hint, I'll edit my answer \$\endgroup\$
    – statox
    Commented Nov 7, 2016 at 22:27
  • 2
    \$\begingroup\$ Haha, yeah I temporarily changed my name because of this challenge, lol. I'll change it back in 30 days \$\endgroup\$
    – DJMcMayhem
    Commented Nov 7, 2016 at 22:36
3
\$\begingroup\$

Brainfuck, 168 bytes

++++++[>++++++++<-]>-<+++++++++[>>++++++++++<<-]>>++<<+++++[>>>++<<<-]>>>>+++[>++++[>++++++[<<<<<.....>.....>>>>-]<<<.>>-]++++[>++++++[<<<<.....<.....>>>>>-]<<<.>>-]<-]
\$\endgroup\$
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\$

x86-16 machine code, IBM PC DOS, 40 39 bytes

Binary:

00000000: b05c b118 b30c f6c1 0375 0234 73ba 0500  .\.......u.4s...
00000010: cd29 4a75 fb34 734b 75f3 50b0 0dcd 29b0  .)Ju.4sKu.P...).
00000020: 0acd 2958 e2de c3                        ..)X...

Listing:

B0 5C           MOV  AL, '\'        ; starting char
B1 18           MOV  CL, 24         ; CX = row counter 
            ROW: 
B3 0C           MOV  BL, 12         ; BX = pattern counter 
F6 C1 03        TEST CL, 3          ; have displayed 4 lines of same direction? 
75 02           JNZ  DIR            ; if not, continue with same 
34 73           XOR  AL, '/' XOR '\'; otherwise, swap the chars 
            DIR: 
BA 0005         MOV  DX, 5          ; DX = char counter 
            PATT: 
CD 29           INT  29H            ; write char to console 
4A              DEC  DX             ; have displayed 5 of the same? 
75 FB           JNZ  PATT           ; if not, keep writing  
34 73           XOR  AL, '/' XOR '\'; otherwise, swap the chars 
4B              DEC  BX             ; have displayed 12 patterns on a line? 
75 F3           JNZ  DIR            ; if not, keep writing patterns 
50              PUSH AX             ; otherwise, save the chars and write a CRLF
B0 0D           MOV  AL, 0DH        ; CR char 
CD 29           INT  29H            ; write to console 
B0 0A           MOV  AL, 0AH        ; LF char 
CD 29           INT  29H            ; write to console 
58              POP  AX             ; restore original chars 
E2 DE           LOOP ROW            ; loop until written 24 lines written 
C3              RET                 ; return to DOS

A standalone PC DOS executable COM program. Output to console:

enter image description here

\$\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\$
0
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\$
3
  • \$\begingroup\$ That explanation was painful to write... wish there was some way to use <something>5"/\\" instead of +*5\/*5\\. \$\endgroup\$ Commented Nov 6, 2016 at 18:09
  • \$\begingroup\$ sC*5]"/\\" There is, but it's a byte longer. \$\endgroup\$
    – Steven H.
    Commented Nov 6, 2016 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
    Commented Nov 6, 2016 at 18:51
2
\$\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\$
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\$
0
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\$
1
  • 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\$ Commented Nov 7, 2016 at 12:45
2
\$\begingroup\$

SOML, 20 bytes

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

R, 72 65 bytes

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

Try it online!

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

Try it online!

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

Uiua 0.11.0, 20 bytes

+@/×45▽3⊂⟜¬↯4_60⊚5_5

See it in action

\$\endgroup\$
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\$
3
  • \$\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\$ Commented Nov 6, 2016 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\$ Commented Nov 6, 2016 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
    Commented Nov 6, 2016 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\$
1
  • \$\begingroup\$ Are there missing newlines? \$\endgroup\$
    – user58632
    Commented Nov 6, 2016 at 14:42
1
\$\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\$
1
\$\begingroup\$

GolfSharp, 59 bytes

r(0,1440).s(n=>n%10<5^n%480<240?"\\":"/").j().S(60).j("\n")
\$\endgroup\$
1
\$\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\$
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\$
2
  • 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
    Commented Nov 6, 2016 at 12:37
  • \$\begingroup\$ Nice. Just tested and it works. Will check the docs on that. \$\endgroup\$
    – ElPedro
    Commented Nov 6, 2016 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\$
2
  • 1
    \$\begingroup\$ Why braces on the second for loop? \$\endgroup\$ Commented Nov 6, 2016 at 20:56
  • \$\begingroup\$ edited @pinkfloydx33 \$\endgroup\$ Commented Nov 9, 2016 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\$
0
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\$

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\$

Excel (loaded with VBA), 70 62 bytes

Formula for each cell (A4 through BH27):

=IF(SIN(COLUMN()*0.62)*SIN(ROW()*0.8)>0,"\","/")

I'm not sure how to score this and I couldn't find a consensus. It's a 48 byte pure Excel formula, the same in every cell (but of course the fact that it should be in a particular range is also information). It takes 62 bytes to load it by executing this in the VBA Immediate window.

[A4:BH27]="=IF(SIN(COLUMN()*.62)*SIN(ROW()*.8)>0,""\"",""/"")" 

Output

Output

\$\endgroup\$
1
  • \$\begingroup\$ Saved 8 bytes by realizing I don't need .Formula in the VBA \$\endgroup\$ Commented Mar 30, 2018 at 23:30
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\$
1
\$\begingroup\$

Pip -n, 24 bytes

(RF('/X6.'\X6)X24)X3<>72

Quad reflect is a bit weird in pip, so this answer uses normal reflect.

The -n flag joins lists with newlines.

Try it online!

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

MAWP, 88 bytes

3[4[6[5[68W1A;1A]%4[68W2A2W;1A]%1A]%52W;1A]4[6[5[68W2A2W;1A]%4[68W1A;1A]%1A]%52W;1A]%1A]

Try it!

Raise the max executions to at least 15000 to test it :D Oh, and be ready to wait for quite some time for it to finish.

MAWP 2.0, 61 bytes

3[4[6["/////\\\\\":1-]`10;1-]`4[6["\\\\\/////":1-]`10;1-]`1-]

Try it!

\$\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.