J, 82 72 66 bytes
(ucp' #───│┌┐┬│└┘┴│├┤┼'){~]+]*3 3((2#.1 7 3 5{,);._3)0,.~0,.0,~0,]
The input is a boolean table of 1's and 0's. The rules state that the box characters each count as one byte, not three, and that has been applied here.
Usage
f =: (ucp' #───│┌┐┬│└┘┴│├┤┼'){~]+]*3 3((2#.1 7 3 5{,);._3)0,.~0,.0,~0,]
m =: 1 0 1 1 1 1 0 1 1 0 1 , 1 1 0 1 0 0 1 1 0 0 1 ,: 0 0 0 1 1 1 1 0 0 1 1
m { ' #'
# #### ## #
## # ## #
#### ##
f m
│ ─┬── ┌─ │
└─ │ ┌┘ │
└──┘ ─┘
' #' {~ m =: 5 5 $ 1
f m
┌┬┬┬┐
├┼┼┼┤
├┼┼┼┤
├┼┼┼┤
└┴┴┴┘
' #' {~ m =: 5 9 $ 1 0
# # # # #
# # # #
# # # # #
# # # #
# # # # #
f m
# # # # #
# # # #
# # # # #
# # # #
# # # # #
Explanation
First the input is padded with 0's on all sides.
] m =: 1 0 1 1 1 1 0 1 1 0 1 , 1 1 0 1 0 0 1 1 0 0 1 ,: 0 0 0 1 1 1 1 0 0 1 1
1 0 1 1 1 1 0 1 1 0 1
1 1 0 1 0 0 1 1 0 0 1
0 0 0 1 1 1 1 0 0 1 1
(0,.~0,.0,~0,]) m
0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 1 1 1 1 0 1 1 0 1 0
0 1 1 0 1 0 0 1 1 0 0 1 0
0 0 0 0 1 1 1 1 0 0 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0
Then each subarray of size 3 is selected
3 3 <;._3 (0,.~0,.0,~0,]) m
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│
│0 1 0│1 0 1│0 1 1│1 1 1│1 1 1│1 1 0│1 0 1│0 1 1│1 1 0│1 0 1│0 1 0│
│0 1 1│1 1 0│1 0 1│0 1 0│1 0 0│0 0 1│0 1 1│1 1 0│1 0 0│0 0 1│0 1 0│
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│0 1 0│1 0 1│0 1 1│1 1 1│1 1 1│1 1 0│1 0 1│0 1 1│1 1 0│1 0 1│0 1 0│
│0 1 1│1 1 0│1 0 1│0 1 0│1 0 0│0 0 1│0 1 1│1 1 0│1 0 0│0 0 1│0 1 0│
│0 0 0│0 0 0│0 0 1│0 1 1│1 1 1│1 1 1│1 1 0│1 0 0│0 0 1│0 1 1│1 1 0│
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│0 1 1│1 1 0│1 0 1│0 1 0│1 0 0│0 0 1│0 1 1│1 1 0│1 0 0│0 0 1│0 1 0│
│0 0 0│0 0 0│0 0 1│0 1 1│1 1 1│1 1 1│1 1 0│1 0 0│0 0 1│0 1 1│1 1 0│
│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│
└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
Then only 5 of the values in each subarray is considered
┌───┐
│xAx│
│CED│
│xBx│
└───┘
The values ABCD
are selected by flattening each subarray and selecting at indices 1 7 3 5
. Those values are multiplied by E
which is at index 4. It is then converted from a list of binary digits to a decimal, and incremented by E
. The x
values are not needed.
3 3 (4&{([+2#.*)1 7 3 5&{)@,;._3 (0,.~0,.0,~0,]) m
5 0 2 8 4 3 0 6 3 0 5
10 3 0 13 0 0 6 11 0 0 13
0 0 0 10 4 4 11 0 0 2 11
This is used as an index to select which character to draw according to the table below (reordered a bit for golfing). The last column matches the output value of each subarray to a box character.
0 (space) 0
1 # 1
2 ┌ 6
3 ┬ 8
4 ┐ 7
5 ├ 14
6 ┼ 16
7 ┤ 15
8 └ 10
9 ┴ 12
10 ┘ 11
11 │ 5, 9, 13
12 ─ 2, 3, 4
Also, in J, the string ' #───│┌┐┬│└┘┴│├┤┼'
uses 8-bit characters making it have a length of 47 (for each byte) for the 17 characters needed. The command ucp
converts it to 16-bit characters which allows it to be length 17.
-|r7LJE3TW+
is a suitable 1-byte-char replacement for the block characters. \$\endgroup\$*
? \$\endgroup\$