20
\$\begingroup\$

I want a blanket that looks like this. Each strip goes over, under, over, under. Can you print it?

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

Trailing spaces at the end of each line and trailing newlines are acceptable.

Remember, this is , so the code with the fewest bytes wins.

Leaderboards

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

# Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

# Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the leaderboard snippet:

# [><>](http://esolangs.org/wiki/Fish), 121 bytes

var QUESTION_ID=99023,OVERRIDE_USER=12537;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\$
11
  • \$\begingroup\$ The right edge seems misaligned. \$\endgroup\$ Commented Nov 8, 2016 at 17:55
  • \$\begingroup\$ Is the left edge not overlapping intended? \$\endgroup\$
    – xnor
    Commented Nov 8, 2016 at 17:56
  • \$\begingroup\$ @xnor Sorry, my bad. \$\endgroup\$
    – Oliver Ni
    Commented Nov 8, 2016 at 17:57
  • \$\begingroup\$ @carusocomputing Fixed. \$\endgroup\$
    – Oliver Ni
    Commented Nov 8, 2016 at 17:58
  • 12
    \$\begingroup\$ Had you used the Sandbox, those issues could have been avoided before this went up on main. \$\endgroup\$
    – user45941
    Commented Nov 9, 2016 at 6:55

25 Answers 25

11
\$\begingroup\$

Python 2, 84 bytes

R=range(24)
for i in R:print''.join(" \// \/\\"[i+~j>>2&1^i+j>>1&2^i&4]for j in R*2)

Thanks to Sp3000 for 6 bytes from turning the arithmetic operations into bitwise ones.

\$\endgroup\$
3
  • \$\begingroup\$ Whoa... how???? \$\endgroup\$
    – Oliver Ni
    Commented Nov 10, 2016 at 5:50
  • 1
    \$\begingroup\$ i+~j>>2&1^i+j>>1&2^i&4, perhaps? \$\endgroup\$
    – Sp3000
    Commented Nov 10, 2016 at 7:13
  • \$\begingroup\$ @Sp3000 That's some nice bitwise precedence. I'll have to remember that when combining arithmetically-derived booleans into an index. \$\endgroup\$
    – xnor
    Commented Nov 10, 2016 at 18:05
7
\$\begingroup\$

Pyth, 36 bytes

V24sm@" \// \/\\"im<3%k8++BNdt-NdT48

Try it online: Demonstration

Explanation:

We can determine the symbol by checking 3 conditions:

A := row % 8 > 3
B := (row + column) % 8 > 3
C := (row - column - 1) % 8 > 3

If we interpret [A,B,C] as a binary number, we get the following mapping:

01234567
 \// \/\

We can also interpret [A,B,C] as decimal number and perform a modular indexed lookup in the string. This doesn't make a difference because 10 mod 8 = 2.

Now to the code:

V24 iterates N (row-idx) over [0, 1, ..., 23].

sm...48 maps the numbers d (column-idx) in [0, 1, ..., 47] to chars and print the combined string.

++BNd generates the list [N, N+d], +...t-Nd appends N-d-1. So we have get the list [N, N+d, N-d-1]. m<3%k8 checks for each computed number k, if 3 < k % 8, so this gives the list with the conditions [A, B, C].

i...T convents this to a decimal number and then @" \// \/\\" does the lookup in the string.

More or less the same code in Python2: 98 bytes:

R=range(8)
for r in R*3:print''.join(" \// \/\\"[4*(r>3)+2*((r+c)%8>3)+((r-c-1)%8>3)]for c in R*6)
\$\endgroup\$
2
  • \$\begingroup\$ Just trying to get to grips with Pyth so any decent answer with a good explanation gets an upvote from me. was going to try Pyth after my base 3 experiment :) \$\endgroup\$
    – ElPedro
    Commented Nov 9, 2016 at 21:02
  • \$\begingroup\$ You should post the Python2 answer as well... \$\endgroup\$ Commented Nov 10, 2016 at 4:14
4
\$\begingroup\$

Python 3, 174 172 138 bytes

print("\n".join(o*6for o in("bbbb////"," bb//// ","  ////  "," ////bb ","////bbbb","b//  bbb","bb    bb","bbb  //b")*3).replace("b","\\"))

Found the smallest pattern I could find in the blanket (the "under" and "over" pattern), stuck it in a list and added some list comprehension and string manipulation to unpack it all. Substituted all escaped backslashes by "b" and replaced them back later to save a few bytes.

Thanks to Oliver for golfing off 2 bytes!

Took 34 bytes off by changing the pattern - the whole pattern for the blanket is now in a single list, so only one for loop is needed to unwrap the pattern.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Welcome to PPCG! nice first post! You can shave a byte in python 2 I think, you don't need the parends for print. \$\endgroup\$
    – Riker
    Commented Nov 9, 2016 at 15:06
  • 1
    \$\begingroup\$ Thank you Easterly Irk, I've been lurking around in code golf for too long now, so I decided to participate. :) \$\endgroup\$ Commented Nov 9, 2016 at 15:16
  • 1
    \$\begingroup\$ You can save two byte by removing the space after 0*6 and u*6 \$\endgroup\$
    – Oliver Ni
    Commented Nov 9, 2016 at 16:04
  • 1
    \$\begingroup\$ You could save 4 bytes by using the "b" for double backslashes and anywhere you need a single backslash just use escaping:print((("\n".join(o*6 for o in("bb////"," b//// "," //// "," ////b ",""))+"\n".join(u*6 for u in("////bb","\\// b\\","b b","b\\ //\\","")))*3).replace("b","\\\\")) \$\endgroup\$
    – dzaima
    Commented Nov 9, 2016 at 19:31
  • \$\begingroup\$ dzaima: your code doesn't seem to generate a valid blanket. \$\endgroup\$ Commented Nov 10, 2016 at 8:19
4
\$\begingroup\$

Python 2, 171 170 168 bytes

a,b,c=r"\\","/"*4," "
f,g=c*2,c+a+b+c
d=(a*2+b)*6,g*6,(f+b+f)*6,g[::-1]*6,(b+a*2)*6,('\\//'+f+a+"\\")*6,(a+f*2+a)*6,(a+"\\"+f+'//\\')*6
for e in 0,1,2:print'\n'.join(d)

Not pretty and not clever. Just sets variables for the most often used groups of strings then combines them and prints the result 3 times. May try and golf it more later if I don't find a better approach.

1 byte saved by using raw input on the a assignment. Thanks @nedla2004

-2 by assigning a couple of variables but still not a serious competitor

\$\endgroup\$
5
  • 1
    \$\begingroup\$ You could define a as r"\\" \$\endgroup\$
    – nedla2004
    Commented Nov 9, 2016 at 17:59
  • \$\begingroup\$ Thanks @nedla2004 Good point. Threw this together pretty quickly and was going to look at it later. That's a good start :) \$\endgroup\$
    – ElPedro
    Commented Nov 9, 2016 at 18:37
  • \$\begingroup\$ Most interested in finding a way round the *6 on each tuple element though. Any ideas? \$\endgroup\$
    – ElPedro
    Commented Nov 9, 2016 at 18:41
  • 1
    \$\begingroup\$ I don't know how you could do that, but the last line can be exec r"print'\n'.join(d);"*3. \$\endgroup\$
    – nedla2004
    Commented Nov 9, 2016 at 20:26
  • \$\begingroup\$ I just posted an alternative just out of interest. Would value your comments on that also. \$\endgroup\$
    – ElPedro
    Commented Nov 9, 2016 at 20:47
4
\$\begingroup\$

Brainfuck, 301 bytes

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

Try it online!

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

Perl, 209 + 17 = 226 bytes

Run with -mList::Util=max -M5.010 (the second flag is free). It's not winning any byte count competitions, but here's my solution.

for(0..7){@b=(1)x8;@b[$_+3..$_+7]=(3)x4;@b[7-$_..10-$_]=(2)x4;for$c(0..2){$b[$c+8]=max$b[$c+8],$b[$c];$b[5-$c]=max$b[5-$c],$b[13-$c];}push@a,sprintf("%-8s",join("",@b[3..10])=~tr[123][ /\\]r)x6;}say for@a,@a,@a

Readable:

for(0..7){
    @b=(1)x8;
    @b[$_+3..$_+7]=(3)x4;
    @b[7-$_..10-$_]=(2)x4;
    for$c(0..2){
        $b[$c+8]=max$b[$c+8],$b[$c];
        $b[5-$c]=max$b[5-$c],$b[13-$c];
    }
    push@a,sprintf("%-8s",join("",@b[3..10])=~tr[123][ /\\]r)x6
}
say for@a,@a,@a

Procedurally generates each segment, then repeats the pattern 6 times, then outputs the total result 3 times.

\$\endgroup\$
3
  • \$\begingroup\$ Woah,I'm not the longest answe any more :) +1 for doing it in Perl anyway. \$\endgroup\$
    – ElPedro
    Commented Nov 9, 2016 at 23:01
  • \$\begingroup\$ I could have done it the same way as everyone else (just printing a bunch of lines), but I decided to do things algorithmically instead of explicitly because I felt it was cooler. \$\endgroup\$ Commented Nov 9, 2016 at 23:10
  • \$\begingroup\$ Cool by my standards. I've taken an approach that I have never tried before cos it was an interesting challenge. As I said, +1. No insult intended by my comment. That's why I upvoted. \$\endgroup\$
    – ElPedro
    Commented Nov 9, 2016 at 23:15
3
\$\begingroup\$

05AB1E, 37 bytes

Uses CP-1252 encoding.

24FNU48FXXN+XN-<)8%3›J" \// \/\"è?}¶?

Try it online!

Explanation

Uses the mod-8 trick expertly explained in Jakube's pyth answer.

24F                                    # for N in [0 ... 23] do:
   NU                                  # save N in X
     48F                               # for N in [0 ... 48] do:
        XXN+XN-<)                      # push [X,X+N,X-N-1]
                 8%                    # mod each by 8
                   3›                  # compare with 3
                     J                 # join
                      " \// \/\"è?     # index into string and print
                                  }    # end inner loop
                                   ¶?  # print newline
\$\endgroup\$
2
\$\begingroup\$

SOML, 106 bytes

3{"\\\\////”6*p" \\//// ”6*p"  ////  ”6*p" ////\\ ”6*p"////\\\\”6*p"\//  \\\”6*p"\\    \\”6*p"\\\  //\”6*p

a non-competing version using a function that I've only recently added: (83 67 66 bytes)

explanation:

  →$\\→#////→@”6*p"→~3{"##@~ #@ ~$@$~ @# ~@##~\//$#\~#$$#~#\$//\~”
  →$                                                                in the further code replace "$" with "  "
    \\→#                                                            replace "#" with "\\"
        ////→@                                                      replace "@" with "////"
              ”6*p"→~3{"##@~ #@ ~$@$~ @# ~@##~\//$#\~#$$#~#\$//\~” the code to exchange stuff in

so that results in:
”6*p"→~3{"\\\\////~ \\//// ~  ////  ~ ////\\ ~////\\\\~\//  \\\~\\    \\~\\\  //\~”
”6*p"→~3{"A~B~C~D~E~F~G~H~”  modified version of the program (removing "/","\" and " " and replaced with A,B,C,ect.)
”6*p"→~                      replace in the further program "~" with ”6*p" which is:
”                            end string
 6*                          repeat the last thing in stack 6 times
   p                         output the result
    "                        start a string
resulting program: 
3{"A”6*p"B”6*p"C”6*p"D”6*p"E”6*p"F”6*p"G”6*p"H”6*p"”
shortened example:
3{"A”6*p"B”6*p"H”6*p"”
3{                      repeat 3 times
  "A”                   push "A" (original: "\\\\////")
     6*p                output it multiplied by 6
        "B”             push "B" (original: " \\//// ")
           6*p          output it multiplied by 6
              "H”       push "H" (original: "\\\  //\")
                 6*p    output it multiplied by 6
                    "”  push an empty string (shorter to do ~” than ”6*p)
\$\endgroup\$
2
\$\begingroup\$

Ruby, 75 bytes

1152.times{|i|$><<"\\/ /\\\\ /"[(i+j=i/48)/4&1|(i-j)/2&2|j&4]+$/*(i%48/47)}

Better golfed, using a single 8-byte string lookup indexed by j&4 in addition to the other parameters, rather than a modifiable 4-byte string.

Ruby, 81 bytes

1152.times{|i|j=i/48%8;$><<"\\#{'/\\'[j/4]} /"[(i+j)/4&1|(i-j)/2&2]+$/*(i%48/47)}

Prints the diagonal stripes character by character. The correct character is selected from a string of 4 characters depending on the presence / absence of each strand. The overlap character is varied depending on which strand is on top.

Commented

1152.times{|i|j=i/48%8;        #Iterate through all printable chars. j is line number.
  $><<"\\#{'/\\'[j/4]} /"[     #Print a char from "\/ /" if j/4 even or "\\ /" if odd. character changes depending which strand on top.
   (i+j)/4&1|(i-j)/2&2]+       #Print \ if (i+j)/4==0, / if (i-j)/2&2 >0, space if both false. As above if both true. 
   $/*(i%48/47)                #If on column 47, print a newline.
}
\$\endgroup\$
2
\$\begingroup\$

Perl, 132 131 113 bytes

@a=((0)x4,1..4);map{say+(map$a[7-$_]?$a[$_]*$r?'/':'\\':$a[$_]?'/':$",0..7)x6;push@a,shift@a;$_%4||($r=!$r)}0..23

Ungolfed:

use strict;
use warnings;
use feature 'say';

my @a = ((1) x 4, (0) x 4);  # print '\' if true
my @b = ((0) x 4, (1) x 4);  # print '/' if true
my $r = 0;                   # print '\' over '/' if true

for (0 .. 23) {
    say((map { $a[$_] ? ($b[$_] * $r ? '/' : '\\') : ($b[$_] ? '/' : ' ') } 0 .. 7) x 6);
    unshift(@a, pop(@a));    # circular shift to left
    push(@b, shift(@b));     # circular shift to right
    $r = !$r if !($_ % 4);   # change print priority
}
\$\endgroup\$
2
\$\begingroup\$

Python, 245 236 234 233 230 216 212 198 195 bytes

OK, longer than my last (and any other) answer but would be interested in feedback on the approach.

for a in(40,4496,6200,5456,3240,1188,720,228)*3:print((`a%6561/2178`+`a%2178/729`+`a%729/243`+`a%243/81`+`a%81/27`+`a%27/9`+`a%9/3`+`a%3/1`)*6).replace('0','\\').replace('1','/').replace('2',' ')

Edit

-9 due to @nedla2004 being more on the ball than me

-2 by taking the lambda outside of the loop and so losing 2 indent spaces

-1 by using in' '*3 instead of in 0,1,2 since I don't use h anyway. it's just a counter.

-3 Why, why, why did I leave a newline and 2 indents between the second for and the print??? It's late. Will revisit tomorrow.

-14 Can actually lose the lambda completely and just include the base 3 decoder directly after the print statement. Looks messy but after all, this is code golf :)

-4 No point setting a variable for the integer list. Just use it directly in the second for loop.

-14 and no point using the outer loop. Just multiply the integer tuple by 3 (shamelessly stolen from @nedla2004 to get under 200 :))

-3 Saved 3 by making \=0, /=1 and space=2. This makes the integer list shorter as three of the base 3 numbers now have leading 0's

How it works (and it does)

Since only 3 characters are used:

  1. l is a list of the 8 repeating patterns as integer equivalents of their base 3 representation assuming that " "=0, "\"=1 and "/"=2

  2. The lambda The first code after the print statement is a lightweight converter from integer to a base 3 string

  3. The first loop loops 3 times and the second prints each line with the base 3 characters multiplied by 6 and replaced with /,\ or space.

I'm sure I could use a regex instead of the nested replace() but I'm too tired to try right now. This was just an experiment and longer than my previous Python effort but have posted just for any comments on the approach (and also because I have never worked in base 3 before and I quite enjoyed working out the converter).

\$\endgroup\$
11
  • 1
    \$\begingroup\$ You could just remove the first division in the base 3 conversion. \$\endgroup\$
    – nedla2004
    Commented Nov 9, 2016 at 21:17
  • \$\begingroup\$ For some reason that was causing me problems earlier but just tried and it works now. many thanks for being more awake than me. I'll re-edit my answer (and you have just saved me 9 bytes :)) \$\endgroup\$
    – ElPedro
    Commented Nov 9, 2016 at 21:20
  • 1
    \$\begingroup\$ I rewrote the base 3 conversion, it is no longer a lambda, I had to make it a function, but it might be able to be converted back to a lambda. You can find the function here. \$\endgroup\$
    – nedla2004
    Commented Nov 9, 2016 at 21:47
  • \$\begingroup\$ Thanks. I think a combination of the two may work but that's probably a job for tomorrow evening :) Thanks again for your comments. \$\endgroup\$
    – ElPedro
    Commented Nov 9, 2016 at 21:52
  • 1
    \$\begingroup\$ I got it down to 169, here. \$\endgroup\$
    – nedla2004
    Commented Nov 9, 2016 at 23:20
2
\$\begingroup\$

Haskell, 96 bytes

f n=n`mod`8`div`4
putStr$unlines[["\\ //\\ \\/"!!(f(x-y)+2*f(x+y)+4*f y)|x<-[0..47]]|y<-[0..23]]
\$\endgroup\$
2
\$\begingroup\$

Ruby, 135 bytes

puts [3320,1212,720,2172,6520,4144,2920,3184].map{|e|(e.to_s(3).rjust(8,"0").gsub("0"," ").gsub("1","\\").gsub("2","/"))*6+"\n"}.join*3

The number array corresponds to each component of each line, translated to base 3: = 0, \ = 1, /= 2, then converted to decimal. The gsub() calls are too big, though.

And, just now, I saw @ElPedro's answer. :-( Just coincidence.

\$\endgroup\$
3
  • \$\begingroup\$ e.to_s(3).rjust(8,"0")("%8s"%e.to_s(3)); gsub("0"," ").gsub("1","\\")..gsub("2","/")tr("013"," \\/"); "\n"$/; .join*"". You can also save a byte by dividing all of the numbers in the array by 4 and replacing e with (e*4). \$\endgroup\$
    – Jordan
    Commented Nov 2, 2017 at 16:25
  • \$\begingroup\$ Oops, I guess that ought to be tr("021"," /\\"). \$\endgroup\$
    – Jordan
    Commented Nov 2, 2017 at 16:31
  • \$\begingroup\$ 90 bytes: tio.run/##DcjNDkUwEEDhV5FJJG0zl6mhauG@CHJDws5PlMUNnr26Ol/Ofg5/… \$\endgroup\$
    – Jordan
    Commented Nov 2, 2017 at 16:37
2
\$\begingroup\$

PHP 157 126 bytes

Taking the changes @Titus lists in the comments... I'm annoyed I missed point 1 which I should have caught, but I didn't know strtr() existed which is where most of the savings come - nice work Titus!

NEW:

while($i<32)echo$b=strtr([3322,' 322 ','0220',' 223 ',2233,12013,3003,13021][$i++%8],['  ','\\','//','\\\\']),"$b$b$b$b$b\n";

OLD:

<?$a=[zzyy,' zyy ',syys,' yyz ',yyzz,xysxz,zssz,xzsyx];while($i<32){$b=$a[$i++%8];$b=str_replace([z,x,y,s],['\\\\','\\','//','  '],$b);echo"$b$b$b$b$b$b
";}

Because all the backslashes need escaping it saves quite a bit of space to pack them up as different character and replace them for output, and then once I'm calling str_replace() it makes sense to use it as often as possible.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ You can remove the open tag if you use -r. Use these five steps to save another 30 bytes: ideone.com/wt4HGB 1) use $a[...] directly as str_replace parameter instead of assigning it. 2) strtr instead of str_replace. 3) Use digits instead of letters. 4) Include the assignment in the echo. 5) Don´t assign $a, just use it. \$\endgroup\$
    – Titus
    Commented Nov 10, 2016 at 14:34
2
\$\begingroup\$

APL (Dyalog Unicode), 36 34 bytes

'\/ /\\ /'[(2⊥3<8|⊣,-⍨,+)/¨⍳24 48]

Try it online!

Because I can't tolerate an APL answer doing so badly.

This is almost a port of Angs' Haskell answer. Uses ⎕IO←0.

How it works

'\/ /\\ /'[(2⊥0⌷2 4⊤⊣,-⍨,+)/¨⍳24 48]
⍳24 48   ⍝ Construct a matrix containing pairs of (0..23),(0..47)
(...)/¨  ⍝ Map over each pair...
⊣,-⍨,+   ⍝   Given two numbers x and y, construct [x,y-x,x+y]
2 4⊤     ⍝   Convert the three numbers to mixed base;
         ⍝   equivalent to n → [n%8/4,n%4] in Python 2
0⌷       ⍝   Extract first row (n%8/4)
2⊥       ⍝   Convert base 2 to integer
'\/ /\\ /'[...]  ⍝ Convert each number in the entire matrix with
                 ⍝ the character at that index
\$\endgroup\$
2
  • \$\begingroup\$ 0⌷2 4⊤ -> 3<8| \$\endgroup\$
    – ngn
    Commented Jul 4, 2020 at 10:50
  • \$\begingroup\$ @ngn Thanks, updated. (Idk why I insisted there) \$\endgroup\$
    – Bubbler
    Commented Jul 6, 2020 at 5:47
1
\$\begingroup\$

Python 2, 169 161 165 160 155 154 152

Based on @ElPedro's answer, with small improvements. To see the explanation, see their answer. This is Python 2, even though there seems to be parenthesis near the print.

Saved 8 bytes by using a variable for replace. That works only for strings, and using a function for it would be longer.

Saved 4 bytes by seeing that @ElPedro realized that they did not need l, and I did not either.

Saved 5 bytes by not flipping the range(8), and instead of using += to append to r, adding r to the end of the new digit. Try it using repl.it

Saved 5 bytes by stealing @ElPedro's new list of values.

Saved 1 byte by removing the space between the in and (.

Saved 2 bytes by removing the variable a.

for x in(40,4496,6200,5456,3240,1188,720,228)*3:
 r=''
 for i in range(8):r=`x/3**i%3`+r
 print(r*6).replace('0','\\').replace('1','/').replace('2',' ')
\$\endgroup\$
7
  • \$\begingroup\$ You can save 1 by removing the space between in and the ( in the first for \$\endgroup\$
    – ElPedro
    Commented Nov 10, 2016 at 10:21
  • \$\begingroup\$ Also I have lost three bytes by reordering the sequence of which numbers represent each character in the base 3 list. See my answer for explanation. feel free to copy. As far as I am concerned this one is a joint effort and I'm happy to see that my original idea had at least some potential :) \$\endgroup\$
    – ElPedro
    Commented Nov 10, 2016 at 19:18
  • \$\begingroup\$ You don't need a=3**i. Just use for i in range(8):r=x/3**i%3+r to save a couple. operator precedence takes care of the rest :) \$\endgroup\$
    – ElPedro
    Commented Nov 10, 2016 at 20:05
  • \$\begingroup\$ Not sure how to delimit the string conversion characters. The parser removed them in my last comment so don't just copy and paste from my suggestion or it will break :) \$\endgroup\$
    – ElPedro
    Commented Nov 10, 2016 at 20:19
  • \$\begingroup\$ Good point, I understood. \$\endgroup\$
    – nedla2004
    Commented Nov 10, 2016 at 20:27
1
\$\begingroup\$

PHP, 184 bytes

<?$p=['1111////',' 11//// ','  ////  ',' ////11 ','////1111','1//  111','11    11','111  //1'];for($j=0;$j<3;$j++)for($i=0;$i<8;$i++)echo str_replace(1,'\\',str_repeat($p[$i],6))."\n";

Output:

C:\PHP>php make-me-a-blanket.php
\\\\////\\\\////\\\\////\\\\////\\\\////\\\\////
 \\////  \\////  \\////  \\////  \\////  \\//// 
  ////    ////    ////    ////    ////    ////  
 ////\\  ////\\  ////\\  ////\\  ////\\  ////\\ 
////\\\\////\\\\////\\\\////\\\\////\\\\////\\\\
\//  \\\\//  \\\\//  \\\\//  \\\\//  \\\\//  \\\
\\    \\\\    \\\\    \\\\    \\\\    \\\\    \\
\\\  //\\\\  //\\\\  //\\\\  //\\\\  //\\\\  //\
\\\\////\\\\////\\\\////\\\\////\\\\////\\\\////
 \\////  \\////  \\////  \\////  \\////  \\//// 
  ////    ////    ////    ////    ////    ////  
 ////\\  ////\\  ////\\  ////\\  ////\\  ////\\ 
////\\\\////\\\\////\\\\////\\\\////\\\\////\\\\
\//  \\\\//  \\\\//  \\\\//  \\\\//  \\\\//  \\\
\\    \\\\    \\\\    \\\\    \\\\    \\\\    \\
\\\  //\\\\  //\\\\  //\\\\  //\\\\  //\\\\  //\
\\\\////\\\\////\\\\////\\\\////\\\\////\\\\////
 \\////  \\////  \\////  \\////  \\////  \\//// 
  ////    ////    ////    ////    ////    ////  
 ////\\  ////\\  ////\\  ////\\  ////\\  ////\\ 
////\\\\////\\\\////\\\\////\\\\////\\\\////\\\\
\//  \\\\//  \\\\//  \\\\//  \\\\//  \\\\//  \\\
\\    \\\\    \\\\    \\\\    \\\\    \\\\    \\
\\\  //\\\\  //\\\\  //\\\\  //\\\\  //\\\\  //\
\$\endgroup\$
1
\$\begingroup\$

PowerShell, 89 bytes

0..23|%{$y=$_
-join(48..94|%{('\/'[$y%8-lt4]+'\/ ')[(($_+$y)%8-lt4)+2*(($_-$y)%8-ge4)]})}

Try it online!

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

05AB1E, 29 bytes

•M;(Ч0—øθε;û…•…/\ Åв8ôJ6×3и»

Try it online!

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

Underload, 130 bytes

((\\\\////)( \\//// )(  ////  )( ////\\ )(////\\\\)(\//  \\\)(\\    \\)(\\\  //\)()(::**:*S(
)S)(:(~*a(a)~*^*)~a*^):*:*:*^!^)::**^

Try it online!

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

Batch, 152 bytes

@call:l
@call:l
:l
@for %%s in (\\\\//// " \\//// " "  ////  " " ////\\ " ////\\\\ "\//  \\\" "\\    \\" "\\\  //\")do @echo %%~s%%~s%%~s%%~s%%~s%%~s

String processing in Batch sucks, so this is probably the best approach. The call-and-fall-through is very slightly shorter than a nested for loop. At least I don't have to quote my backslashes!

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

APL, 110 bytes

I'm new to APL, so this is a simplistic solution.

A←48⍴'\\\\////'⋄B←48⍴' \\//// '⋄C←48⍴'  ////  '⋄F←48⍴'\//  \\\'⋄G←48⍴'\\    \\'⋄24 48⍴A,B,C,(⊖B),(⊖A),F,G,⊖F  

Here's my approach: note that after the first 8 lines of the blanket, the pattern repeats itself. Therefore I only need to define the first 8 lines, and then I can repeat them 3 times. Also note that each line repeats itself after the first 8 characters. Therefore to define a single line I only need to define the first 8 characters and then repeat them 8 times.

Here's an ungolfed solution:

A←48⍴'\\\\////'⋄ ⍝ set A to a 48 element vector (48⍴) of repeated '\\\\////'s
B←48⍴' \\//// '⋄ ⍝ set B to a 48 element vector (48⍴) of repeated ' \\//// 's
C←48⍴'  ////  '⋄ ⍝ ...
D←48⍴' ////\\ '⋄ ⍝ Note that this is actually the reverse of vector B
E←48⍴'////\\\\'⋄ ⍝ Note that this is actually the reverse of vector A
F←48⍴'\//  \\\'⋄
G←48⍴'\\    \\'⋄
H←48⍴'\\\  //\'⋄ ⍝ Note that this is actually the reverse of vector F

24 48 ⍴ A,B,C,D,E,F,G,H ⍝ Make a 24 by 48 character matrix (24 48⍴) by concatenating A,B...H
                        ⍝ and repeating the string until the matrix is full

I noted above that D is the reverse of B, E is the revers of A, and H is the reverse of F. In my actual code, I take advantage of this by not defining D,F, or H and using the reverse function :

24 48⍴A,B,C,(⊖B),(⊖A),F,G,⊖F

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

Ruby, 132 bytes

puts Zlib.inflate Base64.decode64 "eJzt0bENADAMAsGeKdggC/3+cyQRC+A2ipuT3RgJgHWGUjm6VXb2Vjn/3KpJ/qtIPlp1v+XSKZKPVk3y/x5+D6/3sAEUXQ+Q"

very simple answer.

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

Perl 5 + -M5.10.0, 97 bytes

say s/\d(.)/$1x$&/ger x6for('4\4/| 2\4/ |  4/  | 4/2\ |4/4\|\//  3\|2\4 2\|3\  //\\'=~/[^|]+/g)x3

Try it online!

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

JavaScript (Node.js), 127 bytes

_=>String.raw`\\\\////
 \\//// 
  ////  
 ////\\ 
////\\\\
\//  \\\
\\    \\
\\\  //\
`.replace(/.+/g,c=>c.repeat(6)).repeat(3)

Try it online!

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