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

33
\$\begingroup\$

///, 116 bytes

/a/\\\\\\\\\\\\\\\///b/\\\\\\\\\\\\\\\\//A/aaaaa//B/bbbbb//C/ABABABABABAB
//D/BABABABABABA
/CCCCDDDDCCCCDDDDCCCCDDDD

Try it online!

Edit: the \\\\\\\\\\\\\\\/ and \\\\\\\\\\\\\\\\ are actually a single / and \, respectively.

Edit: -3 because I thought of removing i. I think this can't be further golfed.

\$\endgroup\$
1
  • \$\begingroup\$ Language name fits quite well \$\endgroup\$
    – CreaZyp154
    Commented Dec 23, 2021 at 12:32
27
\$\begingroup\$

05AB1E, 18 15 bytes

Code:

„/\5×{4Å6×»6F=R

Explanation:

„/\               # Push the string "/\"
   5×             # Repeat 5 times: "/\/\/\/\/\"
     {            # Sort, resulting in: "/////\\\\\"
      4Å6         # Create a list of 6's with length 4: [6, 6, 6, 6]
         ×        # Vectorized string multiplication
          »       # Join by newlines
           6F     # Do the following six times..
             =    #   Print with a newline without popping
              R   #   Reverse the string

Uses the CP-1252 encoding. Try it online!

\$\endgroup\$
1
  • 3
    \$\begingroup\$ Wow... two different takes, same byte count... \$\endgroup\$
    – Oliver Ni
    Commented Nov 6, 2016 at 14:00
16
\$\begingroup\$

Python 2, 49 bytes

b,a='\/';exec("print(a*5+b*5)*6;"*4+"a,b=b,a;")*6

Thanks to Mitch Schwartz for this clean method that saves a byte. The idea is to print four lines of ('\\'*5+'/'*5)*6, swap the roles of slash and backslash, and then do that whole process 6 times. The two characters are stored in a and b, and swapped as a,b=b,a. The double-loop is double by generating the following code string, then executing it with exec:

print(a*5+b*5)*6;print(a*5+b*5)*6;print(a*5+b*5)*6;print(a*5+b*5)*6;a,b=b,a;print(a*5+b*5)*6;print(a*5+b*5)*6;print(a*5+b*5)*6;print(a*5+b*5)*6;a,b=b,a;print(a*5+b*5)*6;print(a*5+b*5)*6;print(a*5+b*5)*6;print(a*5+b*5)*6;a,b=b,a;print(a*5+b*5)*6;print(a*5+b*5)*6;print(a*5+b*5)*6;print(a*5+b*5)*6;a,b=b,a;print(a*5+b*5)*6;print(a*5+b*5)*6;print(a*5+b*5)*6;print(a*5+b*5)*6;a,b=b,a;print(a*5+b*5)*6;print(a*5+b*5)*6;print(a*5+b*5)*6;print(a*5+b*5)*6;a,b=b,a;

50 bytes:

s='/'*5+'\\'*5;exec("print s*6;"*4+"s=s[::-1];")*6

Makes the line string, prints it four times and then reverses it, then does that 6 times. Does so by generating the following code, then executing it:

print s*6;print s*6;print s*6;print s*6;s=s[::-1];print s*6;print s*6;print s*6;print s*6;s=s[::-1];print s*6;print s*6;print s*6;print s*6;s=s[::-1];print s*6;print s*6;print s*6;print s*6;s=s[::-1];print s*6;print s*6;print s*6;print s*6;s=s[::-1];print s*6;print s*6;print s*6;print s*6;s=s[::-1]

Here are some of the iterations of my golfing:

for c in([1]*4+[-1]*4)*3:print('/'*5+'\\'*5)[::c]*6

for i in range(24):print('/\\'*5+'\/'*5)[i/4%2::2]*6

for c in range(24):print('\\'*5+'/'*5)[::(c&4)/2-1]*6

for i in range(24):print('/'*5+'\\'*5)[::1-i/4%2*2]*6

for c in([1]*4+[0]*4)*3:print('\/'*5+'/\\'*5)[c::2]*6

for c in([1]*4+[0]*4)*3:print('\/'[c]*5+'/\\'[c]*5)*6

for c in(['/\\']*4+['\/']*4)*3:print(c[0]*5+c[1]*5)*6

for c in([5]*4+[-5]*4)*3:print('/'*c+'\\'*5+'/'*-c)*6

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

for x in(['/'*5+'\\'*5]*4+['\\'*5+'/'*5]*4)*3:print x*6

a='/'*5;b='\\'*5
for x in([a+b]*4+[b+a]*4)*3:print x*6

s='/'*5+'\\'*5
for x in([s]*4+[s[::-1]]*4)*3:print x*6

s=('/'*5+'\\'*5)*9
exec("print s[:60];"*4+"s=s[5:];")*6

a='/'*5;b='\\'*5
for i in range(24):print[a+b,b+a][i/4%2]*6
\$\endgroup\$
0
14
\$\begingroup\$

05AB1E, 15 bytes

„/\5×{R6×6FR4F=

Try it online!

Explanation:

„/\             # Push "/\"
   5×           # Repeat string five times: "/\/\/\/\/\"
     {          # Sort: "/////\\\\\"
      R         # Reverse: "\\\\\/////
       6×       # Repeat string six times
         6F     # Repeat the following six times:
           R    #   Reverse
            4F  #   Repeat the following four times:
              = #     Print without popping

Uses the CP-1252 encoding.

\$\endgroup\$
9
\$\begingroup\$

Bubblegum, 30 bytes

00000000: d307 8118 1020 9dc5 3544 3523 f8a4 b386  ..... ..5D5#....
00000010: aae6 e113 cfa3 f13c 1acf a3f1 0c00       .......<......

Obligatory Bubblegum answer.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Oh my goodness this language is awesome! \$\endgroup\$
    – Pedro A
    Commented Nov 7, 2016 at 15:11
8
\$\begingroup\$

JavaScript (ES6), 68 60 58 bytes

A recursive function. Several optimizations inspired from chocochaos answer.

f=(n=1440)=>n--?'/\\'[n/240&1^n/5&1]+(n%60?'':`
`)+f(n):''

Demo

f=(n=1440)=>n--?'/\\'[n/240&1^n/5&1]+(n%60?'':`
`)+f(n):''

console.log(f());

\$\endgroup\$
2
  • \$\begingroup\$ I think you can leave out the first &1 and save two bytes \$\endgroup\$ Commented Nov 7, 2016 at 13:01
  • \$\begingroup\$ @HenrikChristensen That would only work for n < 480. For n >= 480, we'd need parentheses: (n/240^n/5)&1. \$\endgroup\$
    – Arnauld
    Commented Nov 7, 2016 at 13:14
7
\$\begingroup\$

Haskell, 77 70 57 bytes

a%b=(<*[1..a]).([1..b]>>)
unlines$4%3$5%6<$>["/\\","\\/"]

Boring concats and replicates instead of playing with sines. Old was:

unlines[["\\/"!!(ceiling$sin(pi*x/5)*sin(pi*y/4))|x<-[0.5..59]]|y<-[0.5..23]]
\$\endgroup\$
7
\$\begingroup\$

Brainfuck, 140 bytes

>>>++++++++[>++++++>++++++++++++<<-]++++++++++>->----<<<<<+++[>++++[>++++++[>>.....>.....<<<-]>.<<-]++++[>++++++[>>>.....<.....<<-]>.<<-]<-]

:-D

\$\endgroup\$
2
  • 5
    \$\begingroup\$ Oh, look! The brainfuck solution is eight bytes shorter than the Java solution. Time for Java coders to switch to brainfuck... \$\endgroup\$
    – 0WJYxW9FMN
    Commented Nov 7, 2016 at 19:26
  • 1
    \$\begingroup\$ Java strikes back \$\endgroup\$
    – cliffroot
    Commented Nov 7, 2016 at 21:19
7
\$\begingroup\$

Brainfuck, 149 bytes

++++++++++>++++++[>++++++++<-]>->+++++++++[>++++++++++<-]>++>+++[<<++++[<<++++++[>.....>>.....<<<-]<.>>>-]++++[<<++++++[>>>.....<<.....<-]<.>>>-]>>-]

The best interpreter EVAR!

This uses 6 cells (no wrapping, no modulo). Here they are:

0A 00 2F 00 5C 00

The 00 cells are used for the loop counters. Here, the counters are filled in with initial values:

0A 06 2F 04 5C 03

The leftmost counter is for the innermost loop (yes, I use nested loops of depth 3). Please note that the 4th cell (04 counter) is used twice, once for /////\\\\\..., and once for \\\\\/////... every time.

0A, 2F and 5C are the characters \n, / and \, respectively.

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

Pyke, 16 bytes

"/\"6*5m*n+4*sD3

After update today that allowed " in string literals, 17 bytes

"/\\"6*5m*n+4*sD3

Try it here!

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

Python 2, 86 80 76 74 73 bytes

for z in range(24):a=('/'*5+'\\'*5)*24;print((a+a[::-1])*3)[z*60:z*60+60]

Could probably golf a few more off it but it's a start.

Edit

Saved 6 by removing some unneeded brackets

Another 4 by using a single string and then reversing it

Thanks @Adnan. Had a late night last night and still not fully awake yet :p

-1 by moving the *24 to the variable instead of using it twice

\$\endgroup\$
1
  • 5
    \$\begingroup\$ I believe that *6*4 is the same as *24? :p \$\endgroup\$
    – Adnan
    Commented Nov 6, 2016 at 9:38
6
\$\begingroup\$

Python 2.7 66 -> 56 -> 55 bytes

a="/"*5+"\\"*5;b=a[::-1];c=6*a+"\n";d=6*b+"\n";e=4*c+4*d;print e*3

new to code golfing

a="/"*5+"\\"*5;print(4*(6*a+"\n")+4*(6*a[::-1]+"\n"))*3

Thanks Stewie Griffin

Forgot a silly whitespace ;)

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Welcome to PPCG! Nice first answer :) Can you skip some of the intermediate variables? At least d and e, maybe more. I haven't tested this, but it should be close: print(4*c+4*(6*b+"\n"))*3. It's 5 bytes less. \$\endgroup\$ Commented Nov 7, 2016 at 13:40
  • 3
    \$\begingroup\$ 55 bytes: a="/"*5+"\\"*5;print(4*(6*a+"\n")+4*(6*a[::-1]+"\n"))*3 \$\endgroup\$ Commented Nov 7, 2016 at 13:44
6
\$\begingroup\$

Brainfuck, 179 bytes

->++++++++[-<++++++>]++>+++++++++[-<++++++++++>]++++++++++>>>>+++[-<++++[-<++++++[-<+++++[-<<<.>>>]+++++[-<<.>>]>]<<.>>>]++++[-<++++++[-<+++++[-<<.>>]+++++[-<<<.>>>]>]<<.>>>]>]

I know this isn't the best score in the thread but I wanted to try out brainfuck and give this a try.

Edit: I must've made an error while copypasting. This version should work

\$\endgroup\$
3
  • \$\begingroup\$ Welcome to the site! \$\endgroup\$
    – DJMcMayhem
    Commented Nov 7, 2016 at 19:02
  • \$\begingroup\$ Does not work for me. Browser hang up with this interpreter, and personnal one show a non expected 5 line output: /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\ four times, then infinite \ . \$\endgroup\$
    – aluriak
    Commented Nov 8, 2016 at 23:34
  • \$\begingroup\$ Yes, it works :) \$\endgroup\$
    – aluriak
    Commented Feb 26, 2017 at 22:47
5
\$\begingroup\$

Dyalog APL, 24 bytes

(60⍴5/0 4)⊖60/⍪∊3⍴⊂4/'/\'
\$\endgroup\$
3
  • \$\begingroup\$ '/\'[4⌿5/2|+/¨⍳6 12] (requires ⎕io←0) \$\endgroup\$
    – ngn
    Commented Nov 11, 2016 at 18:31
  • \$\begingroup\$ @ngn Why don't you just post it? \$\endgroup\$
    – Adám
    Commented Nov 12, 2016 at 18:33
  • 1
    \$\begingroup\$ done \$\endgroup\$
    – ngn
    Commented Nov 12, 2016 at 18:51
5
\$\begingroup\$

Ruby, 46 bytes

Creates the following string (70 characters, one set more than needed) then alternates between sampling characters 0..59 and 5..64from it.

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

code and output

24.times{|i|puts ((?/*5+?\\*5)*7)[i/4%2*5,60]}

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

interesting mistake (a 7 instead of a 5)

24.times{|i|puts ((?/*5+?\\*5)*7)[i/4%2*7,60]}

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\
\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\
\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\
\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\
\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\
\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\
\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\
\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\
\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\
\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\
\$\endgroup\$
5
\$\begingroup\$

C, 66 61 bytes

5 bytes saved thanks to orlp.

Straightforward character by character printing. 61 characters per row, last is newline (ASCII 10) and the others alternate between /47 and \ 92.

i;f(){for(i=1463;i;)putchar(i--%61?i%61/5+i/244&1?92:47:10);‌​}

//call like this
main(){f();}
\$\endgroup\$
2
  • \$\begingroup\$ 61 bytes: i;f(){for(i=1463;i;)putchar(i--%61?i%61/5+i/244&1?92:47:10);}. \$\endgroup\$
    – orlp
    Commented Nov 6, 2016 at 16:26
  • \$\begingroup\$ @orlp thanks, I knew there had to be a better way with the i-- but I didn´t have time to look for it. \$\endgroup\$ Commented Nov 6, 2016 at 21:58
5
\$\begingroup\$

MATL, 18 16 bytes

'\/'6:&+thK5&Y")

Try it online!

Explanation

'\/'   % Push this string
6:     % Push array [1 2 3 4 5 6]
&+     % 6×6 matrix with all pair-wise additions from that array
th     % Concatenate horizontally with itself. Gives a 6×12 matrix
K      % Push 4
5      % Push 5
&Y"    % Repeat each entry of the matrix 4 times vertically and 5 times horizontally
       % This gives a 24×60 matrix
)      % Index (modularly) into the string. This produces the desired 24×60 char array
\$\endgroup\$
5
\$\begingroup\$

Pyth, 22 bytes

V6V4V12p*5?%+bN2\\\/)k

Try it here.

Explanation:

V6                     Loop 6 times, with N from 0 to 5:
  V4                   Loop 4 times, with H from 0 to 3:
    V12                Loop 12 times, with b from 0 to 11:
      p                Print without newline
        *              The repetition
          5            5 times of
          ?            if
            %          the remainder
              + b N    when the sum of b and N
              2        is divided by 2
          \\           then the "\" character
          \/           else the "/" character
    )                  End
                       (implicitly print with newline)
  k                    k (empty string)
                       (implicit end)
                       (implicit end)

Sorry if the explanation is a little hard to understand, but it was kinda complicated.

\$\endgroup\$
5
\$\begingroup\$

V, 22 21 bytes

Edit One byte won, thanks @DjMcMayhem:

5á\5á/05ä$4Ä5x$p4Ä3ä}

Changes are:

  • Y4P -> Use V duplicate line instead of Vim built-in command (this will add a blank line at the end of the paragraph)
  • 3äG -> 3ä} Duplicate the paragraph instead of the whole buffer (to avoid blank line generated by previous change)

Original post

5á\5á/05ä$Y4P5x$p4Ä3äG

Try it online

Decomposed like this:

5á\                    Write 5 \
   5á/                 Write 5 / after
      0                Go to the beginning of the line
       5ä$             Copy the text to the end of the line and repeat it 5 times
          Y4P          Copy the line and create 4 new copies
             5x$p      Delete the 5 first characters and put them at the end of the line
                 4Ä    Duplicate this line
                   3äG Duplicate the whole text
\$\endgroup\$
5
  • \$\begingroup\$ It's cool to see someone else using V! Up until recently, it's only been me. If you ever need help with it, feel free to ping me in the nineteenth byte \$\endgroup\$
    – DJMcMayhem
    Commented Nov 9, 2016 at 15:39
  • \$\begingroup\$ @DrMcMoylex Yup your language seems fun to use :-) I had a problem on this one: initially I wanted to use 5á\5á/05ä$5Ä5x$p4Ä3äG i.e. replace Y4P by but for a reason that I don't understand it copies an additional blank line... If you can enlighten me on this one it would be nice. Also if I find some free time i'd gladly contribute to the language (especially issue #4) \$\endgroup\$
    – statox
    Commented Nov 9, 2016 at 15:45
  • \$\begingroup\$ Ah, yes that has troubled me many times. It's a known issue. The problem is that Ä is a synonym for dd, not Y. This is usually not an issue, but it causes some problems if the buffer has only one line or if you're on the last line. \$\endgroup\$
    – DJMcMayhem
    Commented Nov 9, 2016 at 15:48
  • \$\begingroup\$ Actually, I just realized, that approach would still work if you replaced 3äG with 3ä} since it won't yank that last newline. v.tryitonline.net/… \$\endgroup\$
    – DJMcMayhem
    Commented Nov 9, 2016 at 15:49
  • \$\begingroup\$ Ok I think I get why it didn't work now. And nice way to win 1 byte, thanks! \$\endgroup\$
    – statox
    Commented Nov 9, 2016 at 15:56
4
\$\begingroup\$

Jelly, 17 16 bytes

⁾/\ẋ6Wẋ4;U$ẋ3x5Y

Try it online!

Thanks to 6710 (miles) for -1 byte.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I think you can save a byte with ⁾/\ẋ6Wẋ4;U$ẋ3x5Y \$\endgroup\$
    – miles
    Commented Nov 6, 2016 at 9:41
  • \$\begingroup\$ @miles Thanks, it seems I can't effectively use quicks yet :) And I knew I didn't need two Ys! \$\endgroup\$ Commented Nov 6, 2016 at 9:45
4
\$\begingroup\$

Actually, 21 bytes

"/\"5*SR6*;4α@R4α+3αi

Try it online!

-1 byte from Adnan

Explanation:

"/\"5*SR6*;4α@R4α+3αi
"/\"5*                 "/\" repeated 5 times
      SR               sort and reverse (result: "\\\\\/////")
        6*             repeat string 6 times (forms one row)
          ;4α          copy and push a list containing 4 copies
             @R4α+     push a list containing 4 copies of the reversed string, append to previous list (now we have one row of diamonds)
                  3α   repeat pattern vertically 2 more times
                    i  flatten and implicitly print
\$\endgroup\$
2
  • \$\begingroup\$ Can you do something like "/\"5*S for creating the string of slashes? \$\endgroup\$
    – Adnan
    Commented Nov 6, 2016 at 9:44
  • \$\begingroup\$ @Adnan Great idea! \$\endgroup\$
    – user45941
    Commented Nov 6, 2016 at 9:45
4
\$\begingroup\$

J, 31 28 19 bytes

4#_60]`|.\5#72$'/\'

Usage

   4#_60]`|.\5#72$'/\'
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\$\endgroup\$
0
4
\$\begingroup\$

APL, 30 bytes

A←240⍴'/////\\\\\'⋄24 60⍴A,⊖A

I'm quite new to APL, (I'm using APLX, but this should work across most implementations of APL), so this is a quite simplistic solution.

Explanation:

A ← 240 ⍴ '/////\\\\\' ⍝ set A to be a 240 character vector populated with '/////\\\\\'
⋄                      ⍝ statement separator
24 60 ⍴ A,⊖A           ⍝ populate a 24 by 60 character matrix with the concatenation 
                          of A and the reverse of A (⊖A)
\$\endgroup\$
3
\$\begingroup\$

Python 2, 63 bytes

a='\n'.join([('/'*5+'\\'*5)*6]*4);print'\n'.join([a,a[::-1]]*3)

For Python 3, do this (65 bytes):

a='\n'.join([('/'*5+'\\'*5)*6]*4);print('\n'.join([a,a[::-1]]*3))
\$\endgroup\$
3
  • 1
    \$\begingroup\$ This uses the same method as my Jelly answer. \$\endgroup\$ Commented Nov 6, 2016 at 9:13
  • \$\begingroup\$ More efficient method than mine to start with \$\endgroup\$
    – ElPedro
    Commented Nov 6, 2016 at 9:23
  • \$\begingroup\$ @ElPedro Basically, I just did some string/array manipulation. The trick is that I have prepared a bigger string: /////\\\\\/////... four times, separated by newlines \$\endgroup\$ Commented Nov 6, 2016 at 9:26
3
\$\begingroup\$

Self-modifying Brainfuck, 91 bytes

>>+++[<++++[<++++++[<.....<.....>>-]<<<.>>>>-]++++[<++++++[<<.....>.....>-]<<<.>>>>-]>-]
\/

Try it online!

Same as my brainfuck answer, but uses the 3 last characters of the source code instead of generating them at runtime.

\$\endgroup\$
3
\$\begingroup\$

Octave, 50 48 bytes

Anonymous function:

@()repmat([A=repmat(47,4,5) B=A*2-2;B A ''],3,6)

You can try online here. Simply run the above command and then run the function with ans().

Essentially this creates an array of the value 47 which is 4 high and 5 wide. It then creates a second array of value 92 which is the same size.

The two arrays are concatenated into a checkerboard of [A B;B A]. The '' is concatenated as well to force conversion to character strings.

Finally the whole array is replicated 3 times down and 6 times across to form the final size.


  • Saved 2 bytes, thanks @StewieGriffin
\$\endgroup\$
5
  • \$\begingroup\$ no need for an anonymous function; save 3 bytes. \$\endgroup\$ Commented Nov 9, 2016 at 10:48
  • \$\begingroup\$ @TasosPapastylianou there is, otherwise it will print ans= before the pillow. Having it in the function gets around this as it is expected to return the answer to a variable rather than displaying it. \$\endgroup\$ Commented Nov 9, 2016 at 11:04
  • \$\begingroup\$ That's just semantics. I mean, if you're going to be pedantic I'd worry more about the 3-line warning messages that appear instead :p Also the usual rules state that it needs to be either an output from a direct terminal command, or a callable function handle. Meaning you should assign your anonymous function to a handle (or add another 5 bytes to account for having to pring ans()). Which is pointless, since ans() still prints ans when run! \$\endgroup\$ Commented Nov 9, 2016 at 11:42
  • \$\begingroup\$ @TasosPapastylianou ans() is a callable function handle, so you don't need to assign it to something with, e.g. a=@..., because it is implicitly assigned to ans as a handle. Also it doesn't print ans= when run unless you specifically ask it to by not doing anything with the returned value and not adding a ;. If you did disp(ans()) it would only print the exact output (no ans=). But yes, the warning is annoying, however that didn't happen previously, so it isn't language specific, but rather interpreter specific. \$\endgroup\$ Commented Nov 9, 2016 at 13:27
  • \$\begingroup\$ Ok, we'll agree to disagree. The way I see it, if you're relying on disp(ans()) before getting your output, then you need to add 12 bytes to your answer. My own opinion is that this is just the way octave presents its result and that's fine. \$\endgroup\$ Commented Nov 9, 2016 at 16:14
3
\$\begingroup\$

PHP, 73 69 bytes

for($s='/\\';$i<1440;$i++)echo$i%60<1?'
':'',$s[($i/5+($i/240|0))%2];

Demo

http://ideone.com/z7N1Md

\$\endgroup\$
4
  • 1
    \$\begingroup\$ 69 bytes: for($s='/\\';$i<1440;$i++)echo$i%60<1?'\n':'',$s[($i/5+($i/240|0))%2]; (replace the \n with a real newline). echo isn't a function, so, it doesn't need parenthesys. Also, echo can receive multiple values, separated by a comma. This really removes the need for those parenthesys. And then, inside your $s[...], the outer-most calculation doesn't need parenthesys either, since it is contained withing []. Using $s[($i/5+($i/240|0))%2] has the same effect and is shorter. \$\endgroup\$ Commented Nov 6, 2016 at 18:39
  • \$\begingroup\$ Thank you, updated! I didn't even know about echo accepting multiple parameters ^_^ \$\endgroup\$
    – chocochaos
    Commented Nov 6, 2016 at 21:24
  • \$\begingroup\$ echo and print accept multiple parameters. But print requires parenthesys with multiple parameters when used on a loop's increment, condition or assignment. \$\endgroup\$ Commented Nov 7, 2016 at 0:08
  • \$\begingroup\$ Can shave off that <1, by switching the expressions, echo$i%60?'':' ',, new line as expression 3 in the ternary. \$\endgroup\$
    – Progrock
    Commented Nov 9, 2016 at 15:56
3
\$\begingroup\$

APL, 16

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

Try it on tryapl.org

\$\endgroup\$
3
\$\begingroup\$

Java 7, 120 bytes

String c(){String r="";for(int i=0;i<1440;r+=(i%60<1?"\n":"")+(i/60%8<4?i%10<5?"/":"\\":i%10<5?"\\":"/"),i++);return r;}

Pushed everything into one loop. Beats Brainfuck, mission accomplished.

See it online: https://ideone.com/pZjma3

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