10
2
Given
- a matrix
a
of characters fromu=" ╶╺╵└┕╹┖┗╴─╼┘┴┶┚┸┺╸╾━┙┵┷┛┹┻╷┌┍│├┝╿┞┡┐┬┮┤┼┾┦╀╄┑┭┯┥┽┿┩╃╇╻┎┏╽┟┢┃┠┣┒┰┲┧╁╆┨╂╊┓┱┳┪╅╈┫╉╋"
- the coordinates of a submatrix as
x
,y
,w
,h
(left, top, width>1, height>1) - a thickness
t
of 1 (as in┌
) or 2 (as in┏
)
render an inner border for the submatrix with the specified thickness, taking into account existing lines.
x=4;y=1;w=2;h=3;t=2;
a=[' ┌───┐',
'┌┼┐ │',
'│└┼──┘',
'└─┘ ']
// output
r=[' ┌───┐',
'┌┼┐ ┏┪',
'│└┼─╂┨',
'└─┘ ┗┛']
When overwriting a line fragment, the new thickness should be the greater of
the old thickness and t
.
This isn't about input parsing or finding the Kolmogorov complexity of Unicode,
so you may assume a
,u
,x
,y
,w
,h
,t
are available to you as variables.
Also, you may put the result in a variable r
instead of returning or
outputting it, as long as r
is of the same type as a
.
If your language forces you to put code in functions (C, Java, Haskell, etc) and your solution consists of a single function, you can omit the function header and footer.
Larger test:
x=4;y=1;w=24;h=4;t=1;
a=['┏┱─────┐ ┌┐ ┎──┲━┓',
'┠╂─────┘ ││ ┃ ┗━┛',
'┃┃ ││ ┃ ',
'┠╂──┲━━┓ ┏━━━━┓ ││ ┌╂┰┐ ',
'┃┃ ┗━━┩ ┃ ┃ └╆━┓ └╂┸┘ ',
'┃┃ │ ┃ ┃ ┃ ┃ ┃ ',
'┗┹─────┘ ┗━━━━┛ ┗━┛ ╹ ']
// output
r=['┏┱─────┐ ┌┐ ┎──┲━┓',
'┠╂──┬──┴─────────┼┼─────╂──╄━┛',
'┃┃ │ ││ ┃ │ ',
'┠╂──╆━━┓ ┏━━━━┓ ││ ┌╂┰┐│ ',
'┃┃ ┗━━╃──╂────╂─┴╆━┱──┴╂┸┴┘ ',
'┃┃ │ ┃ ┃ ┃ ┃ ┃ ',
'┗┹─────┘ ┗━━━━┛ ┗━┛ ╹ ']
will the input always hold
0 <= x < x + w < width(a)
and0 <= y < y + h < height(a)
? – tsh – 2017-08-29T10:30:18.583@tsh yes, input will be valid – ngn – 2017-08-29T10:42:39.407
Bah, my default font is dodgy - it shows some of those characters with the wrong heaviness unless you zoom in a lot. – Neil – 2017-08-29T11:51:36.960
@Neil I'm sorry about that. One workaround is to paste the examples in an editor where you can choose the font. – ngn – 2017-08-29T12:04:16.027
1About your bounty - it is impossible to award three 150-rep bounties. You have to double the rep count every time you start another bounty on the same question. – MD XF – 2017-09-05T20:42:17.710
@MDXF Oh... I didn't think about that. Thanks. There must be ways around it though, e.g. start a bounty on a fake question. – ngn – 2017-09-05T22:17:37.037