Visualise Bit Weaving
PowerShell v2+, 172 153 148 145 142 131 123 bytes (81 chars)
($a=""+0..7)
$b='┌┘'
"│$b$('┌┼─┘'*3)
└┼┐$('│└─┐'*3)
$b$('└┼─┐'*3)│
│ $($b*6)│"
$a
I golfed the weaving further, eliminating the need for several variables by using inline code blocks. This is probably within a few bytes of optimal.
We start by setting $a
equal to the range 0..7
that's been joined together with spaces. This is because the default $ofs
(Output Field Separator) for an array is a space, so when the array is stringified with ""+
(with an operator like this, PowerShell will try to implicitly cast the right-hand object as the left-hand object), the result is the range space-separated.
That's encapsulated in parens, which adds the result onto the pipeline. We then setup a one helper variable $b
, followed by four lines of output with the appropriate variable in place (split with literal newlines), and using inline code-blocks for repeat sections, followed by $a
again. The four lines and $a
are also placed on the pipeline, and output is implicit at the end.
PS C:\Tools\Scripts\golfing> .\visualize-bit-weaving.ps1
0 1 2 3 4 5 6 7
│┌┘┌┼─┘┌┼─┘┌┼─┘
└┼┐│└─┐│└─┐│└─┐
┌┘└┼─┐└┼─┐└┼─┐│
│ ┌┘┌┘┌┘┌┘┌┘┌┘│
0 1 2 3 4 5 6 7
Actually, 69 bytes
"│ ┌┘│ │└┐ │└┐└┐""┌┘└┼┐└┼┐ └┼┐└┐""└┼┐│└┐┌┘└┐┌┘│""┌┼─┘"3*"│┌┘"+8r' j;)
Try it online! (the alignment is a little messed up in the online interpreter)
Actually has a HUGE advantage here - all of the box drawing characters are in CP437, so they're only a byte each. Though each character needed could theoretically be encoded in 4 bits (since there are only 9 unique characters), the 31 bytes saved by compressing the string would be lost due to Actually's very poor string processing capabilities. This also means that any 8x4 configuration would result in the same score. Since 8x4 appears to be the (vertically) shortest possible configuration, this is optimal.
Thanks to Martin for 3 bytes!
Thanks to TimmyD for 4 more bytes!
Explanation:
"│ ┌┘│ │└┐ │└┐└┐""┌┘└┼┐└┼┐ └┼┐└┐""└┼┐│└┐┌┘└┐┌┘│""┌┼─┘"3*"│┌┘"+8r' j;)
"│ ┌┘│ │└┐ │└┐└┐""┌┘└┼┐└┼┐ └┼┐└┐""└┼┐│└┐┌┘└┐┌┘│""┌┼─┘"3*"│┌┘"+ push the individual lines, using string multiplication to shorten repeated sections
8r' j push the string "0 1 2 3 4 5 6 7" (range(8), join on spaces)
;) make a copy and move it to the bottom of the stack
Javascript ES6, 168 167 bytes
Edit: Whoops, turned out I was using the pipe |
char instead of U+2502 │
in part of the function, updated byte count.
_=>((n=`0 1 2 3 4 5 6 7 `)+[...`6452301`].map(i=>`${(d=n=>`│ `.repeat(n))(i)}└┐│ ${r=d(6)}┌┼┘ ${r}│└┐ ${d(6-i)}`).join``+n).match(/.{16}/g).join`
`
Returns a string.
Output:
0 1 2 3 4 5 6 7
│ │ │ │ │ │ └┐│
│ │ │ │ │ │ ┌┼┘
│ │ │ │ │ │ │└┐
│ │ │ │ └┐│ │ │
│ │ │ │ ┌┼┘ │ │
│ │ │ │ │└┐ │ │
│ │ │ │ │ └┐│ │
│ │ │ │ │ ┌┼┘ │
│ │ │ │ │ │└┐ │
│ │ └┐│ │ │ │ │
│ │ ┌┼┘ │ │ │ │
│ │ │└┐ │ │ │ │
│ │ │ └┐│ │ │ │
│ │ │ ┌┼┘ │ │ │
│ │ │ │└┐ │ │ │
└┐│ │ │ │ │ │ │
┌┼┘ │ │ │ │ │ │
│└┐ │ │ │ │ │ │
│ └┐│ │ │ │ │ │
│ ┌┼┘ │ │ │ │ │
│ │└┐ │ │ │ │ │
0 1 2 3 4 5 6 7
Extra: Using @TimmyD's method, I have another 167 byte solution:
(n=`0 1 2 3 4 5 6 7
`,a=`│┌┘ `,b=`└┼─┐`,d=`┌┼─┘`,f=` │└┐`)=>[n,a,a,a,a,`
`,b,b,b,`└┼┐
┌┘`,d,d,d,`│
│`,f,f,f,` │
`,n].join``