# Boolean Rectangles [duplicate]

Inspired by Braille graphics

Given a Boolean matrix (i.e., consisting of only 1s and 0s), output an ASCII-art-style Unicode representation of the closed-polygon shape created by the 1s in the matrix, using the Unicode drawing characters ┌ ─ ┐ │ └ ┘ (code points 0x250c, 0x2500, 0x2510, 0x2502, 0x2514, and 0x2518, respectively, separated by spaces). Replace the 0s with spaces, so you're left with just the line drawing. Output or return that drawing.

You won't have to handle invalid or ambiguous input - there will be only one unambiguous path of 1s through the matrix. In other words, every 1 has exactly two cardinal neighbors that are 1s, and two that are 0s or out of bounds. Additionally, since the shape is a closed-polygon, this guarantees that the path is cyclical.

Examples:

[[1,1,1]
[1,0,1]
[1,1,1]]

┌─┐
│ │
└─┘

[[0,1,1,1,1,0],
[1,1,0,0,1,1],
[1,0,0,0,0,1],
[1,1,1,1,1,1]]

┌──┐
┌┘  └┐
│    │
└────┘

[[1,1,1,0,0]
[1,0,1,1,1]
[1,0,0,0,1]
[1,1,0,1,1]
[0,1,1,1,0]]

┌─┐
│ └─┐
│   │
└┐ ┌┘
└─┘

[[1,1,1,0]
[1,0,1,1]
[1,1,0,1]
[0,1,1,1]]

┌─┐
│ └┐
└┐ │
└─┘

• Leading or trailing newlines or whitespace are all optional, so long as the characters themselves line up correctly.
• Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
• If possible, please include a link to an online testing environment so other people can try out your code!
• Standard loopholes are forbidden.
• This is so all usual golfing rules apply, and the shortest code (in bytes) wins.
• What are the codepoints for the relevant drawing characters? Aug 31, 2017 at 18:24
• @PeterTaylor Good point. Added. Aug 31, 2017 at 18:29
• I believe this is a dupe since my Jelly solution works with this input TIO. It could probably be shortened since there will only be one path here instead of multiple like in the other. Aug 31, 2017 at 18:44
• @miles Dagnabbit. I thought this was a duplicate, but 48+ hours in the Sandbox and several searches by me didn't find one. Aug 31, 2017 at 19:14
• @AdmBorkBork The usual tip: after you type the title, a list with possible duplicates goes below the title. You can check there, although the titles in this case were quite different. Sep 1, 2017 at 8:08

# Javascript (ES6), 125 bytes

a=>a.map((r,i)=>r.map((c,j)=>c&&"─ ┌└  ┐┘ |"[!(a[i-1]||0)[j]+!(a[i+1]||0)[j]*2+!r[j-1]*4+!r[j+1]*8-3]||" ").join).join



Example code snippet:

f=
a=>a.map((r,i)=>r.map((c,j)=>c&&"─ ┌└  ┐┘ |"[!(a[i-1]||0)[j]+!(a[i+1]||0)[j]*2+!r[j-1]*4+!r[j+1]*8-3]||" ").join).join

o.innerText=f([[1,1,1,0,0],
[1,0,1,1,1],
[1,0,0,0,1],
[1,1,0,1,1],
[0,1,1,1,0]])
<pre id=o>