30
1
You are working as an intern for a mathematician who really hates TeX, LaTeX, etc. So much so that he has decided to abandon all typesetting whatsoever and make you do all the formatting in ASCII. You got tired of this after a while and decided to start automating parts of it, starting with square roots.
Here's how a square root is made:
### this is the input
###
###
_____ put a row of underscores stretching one character off either side on top
###
###
###
_____ put a diagonal of slashes in front going the height of the input
/ ###
/ ###
/ ###
_____ put a diagonal of backslashes in front of that, going up half of the input's height rounded up
/ ###
\ / ###
\/ ###
And that's it!
Rules
You are to make a program or function that takes in a string, list of strings (i.e. lines), or array of characters, and outputs the input transformed according to the description above (not necessarily by the exact same order or process)
You may assume that the input is rectangular if preferred. Trailing whitespace is neither required nor disallowed.
This is code-golf, so the shortest answer in bytes wins.
Examples:
Input:
40
Output:
____
\/ 40
Input:
____
\/ 40
Output:
________
/ ____
\/ \/ 40
Input:
/|
|
|
_|_
Output:
_____
/ /|
/ |
\ / |
\/ _|_
Input:
# #
# #
#####
#
#
Output:
_______
/ # #
/ # #
\ / #####
\ / #
\/ #
3V is gonna do well in this one – caird coinheringaahing – 2017-07-25T21:09:12.610
16a mathematician who really hates TeX, LaTeX etc I almost quit reading right there – Luis Mendo – 2017-07-25T23:04:34.287
5You are working I almost quit reading right there – Arnauld – 2017-07-26T17:46:20.597