| Bytes | Lang | Time | Link |
|---|---|---|---|
| 127 | JavaScript Node.js | 240807T061600Z | Andrew B |
| 301 | Brainfuck | 200902T093354Z | RezNesX |
| 097 | Perl 5 + M5.10.0 | 200710T114722Z | Dom Hast |
| 130 | Underload | 200709T215617Z | Madison |
| 034 | APL Dyalog Unicode | 200702T051957Z | Bubbler |
| 029 | 05AB1E | 200227T164722Z | Grimmy |
| 089 | PowerShell | 200227T132428Z | mazzy |
| 184 | PHP | 161111T141343Z | Mario |
| 126 | PHP | 161109T095935Z | ToXik-yo |
| 135 | Ruby | 161110T221847Z | jose_cas |
| 096 | Haskell | 161110T214551Z | Angs |
| 168 | Python 2 | 161109T174820Z | ElPedro |
| 152 | Python 2 | 161110T001747Z | nedla200 |
| 195 | Python | 161109T204632Z | ElPedro |
| 084 | Python 2 | 161110T041703Z | xnor |
| 036 | Pyth | 161109T203307Z | Jakube |
| 037 | 05AB1E | 161110T105950Z | Emigna |
| 113 | Perl | 161109T203227Z | Denis Ib |
| 138 | Python 3 | 161109T145738Z | TheCrazy |
| 132 | Ruby | 161110T034916Z | anna328p |
| 110 | APL | 161110T015525Z | ren |
| 075 | Ruby | 161110T004013Z | Level Ri |
| 152 | Batch | 161109T223544Z | Neil |
| 106 | SOML | 161109T180401Z | dzaima |
| nan | Perl | 161109T160354Z | Gabriel |
JavaScript (Node.js), 127 bytes
_=>String.raw`\\\\////
\\////
////
////\\
////\\\\
\// \\\
\\ \\
\\\ //\
`.replace(/.+/g,c=>c.repeat(6)).repeat(3)
Brainfuck, 301 bytes
-[>+<-----]-[>>+<<---]>---->+++++++>>++++[<++++++++>-]>+++>++++++++++<[-<++++++[-<<....<....>>>]>>.<<++++++[-<.<..<....>>.>]>>.<<++++++[-<..<<....>>..>]>>.<<++++++[-<.<<....>..>.>]>>.<<++++++[-<<<....>....>>]>>.<<++++++[-<<.<..>>..<...>>]>>.<<++++++[-<<..>....<..>>]>>.<<++++++[-<<...>..<<..>.>>]>>.<]
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
Underload, 130 bytes
((\\\\////)( \\//// )( //// )( ////\\ )(////\\\\)(\// \\\)(\\ \\)(\\\ //\)()(::**:*S(
)S)(:(~*a(a)~*^*)~a*^):*:*:*^!^)::**^
APL (Dyalog Unicode), 36 34 bytes
'\/ /\\ /'[(2⊥3<8|⊣,-⍨,+)/¨⍳24 48]
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
PowerShell, 89 bytes
0..23|%{$y=$_
-join(48..94|%{('\/'[$y%8-lt4]+'\/ ')[(($_+$y)%8-lt4)+2*(($_-$y)%8-ge4)]})}
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
\\\\////\\\\////\\\\////\\\\////\\\\////\\\\////
\\//// \\//// \\//// \\//// \\//// \\////
//// //// //// //// //// ////
////\\ ////\\ ////\\ ////\\ ////\\ ////\\
////\\\\////\\\\////\\\\////\\\\////\\\\////\\\\
\// \\\\// \\\\// \\\\// \\\\// \\\\// \\\
\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\
\\\ //\\\\ //\\\\ //\\\\ //\\\\ //\\\\ //\
\\\\////\\\\////\\\\////\\\\////\\\\////\\\\////
\\//// \\//// \\//// \\//// \\//// \\////
//// //// //// //// //// ////
////\\ ////\\ ////\\ ////\\ ////\\ ////\\
////\\\\////\\\\////\\\\////\\\\////\\\\////\\\\
\// \\\\// \\\\// \\\\// \\\\// \\\\// \\\
\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\
\\\ //\\\\ //\\\\ //\\\\ //\\\\ //\\\\ //\
\\\\////\\\\////\\\\////\\\\////\\\\////\\\\////
\\//// \\//// \\//// \\//// \\//// \\////
//// //// //// //// //// ////
////\\ ////\\ ////\\ ////\\ ////\\ ////\\
////\\\\////\\\\////\\\\////\\\\////\\\\////\\\\
\// \\\\// \\\\// \\\\// \\\\// \\\\// \\\
\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\
\\\ //\\\\ //\\\\ //\\\\ //\\\\ //\\\\ //\
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.
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.
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]]
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
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 That works only for strings, and using a function for it would be longer.replace.
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',' ')
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:
l is a list of the 8 repeating patterns as integer equivalents of their base 3 representation assuming that " "=0, "\"=1 and "/"=2
The lambdaThe first code after the print statement is a lightweight converter from integer to a base 3 stringThe 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).
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.
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)
05AB1E, 37 bytes
Uses CP-1252 encoding.
24FNU48FXXN+XN-<)8%3›J" \// \/\"è?}¶?
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
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
}
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.
Ruby, 132 bytes
puts Zlib.inflate Base64.decode64 "eJzt0bENADAMAsGeKdggC/3+cyQRC+A2ipuT3RgJgHWGUjm6VXb2Vjn/3KpJ/qtIPlp1v+XSKZKPVk3y/x5+D6/3sAEUXQ+Q"
very simple answer.
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
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.
}
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!
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)
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.