27
1
Any regular hexagon can be tiled with diamonds, for instance like so:
______
/_/_/\_\
/_/\_\/\_\
/\_\/_/\/_/\
\/_/\_\/_/\/
\_\/_/\_\/
\_\_\/_/
We'll consider the above a tiling of size 1 (since the diamonds' sides are made of one / or \ each). The same tiling of size 2 would look like:
____________
/ / /\ \
/___/___/ \___\
/ /\ \ /\ \
/___/ \___\/ \___\
/\ \ / /\ / /\
/ \___\/___/ \/___/ \
\ / /\ \ / /\ /
\/___/ \___\/___/ \/
\ \ / /\ \ /
\___\/___/ \___\/
\ \ \ / /
\___\___\/___/
Your task is to receive such an ASCII art tiling (of size 1) as input, along with a positive integer N (in decimal or unary), specifying the size of the desired output. You should then output a scaled-up version of the same tiling.
Note that the hexagon could be any size and as small as 1x1x1 (containing three diamonds).
Neither input nor output must contain any trailing spaces, nor more leading spaces than necessary to align the hexagon shape. Both input and output may optionally contain a single trailing newline (this choice does not have to be the same for input and output).
You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.
This is code golf, so the shortest answer (in bytes) in wins.
Example Tilings
Here are a handful of input tilings you can use to test your submission.
__
/_/\
\_\/
____
/_/\_\
/\_\/_/\
\/_/\_\/
\_\/_/
______
/_/_/\_\
/_/\_\/\_\
/\_\/_/\/_/\
\/_/\_\/_/\/
\_\/_/\_\/
\_\_\/_/
________
/_/\_\_\_\
/\_\/\_\_\_\
/\/_/\/_/_/\_\
/\/\_\/_/_/\/\_\
\/\/_/\_\_\/\/_/
\/\_\/_/\_\/_/
\/\_\_\/_/_/
\/_/_/_/_/
The following snippet contains the corresponding outputs for inputs N = 1 through N = 6.
__
/_/\
\_\/
____
/ /\
/___/ \
\ \ /
\___\/
______
/ /\
/ / \
/_____/ \
\ \ /
\ \ /
\_____\/
________
/ /\
/ / \
/ / \
/_______/ \
\ \ /
\ \ /
\ \ /
\_______\/
__________
/ /\
/ / \
/ / \
/ / \
/_________/ \
\ \ /
\ \ /
\ \ /
\ \ /
\_________\/
____________
/ /\
/ / \
/ / \
/ / \
/ / \
/___________/ \
\ \ /
\ \ /
\ \ /
\ \ /
\ \ /
\___________\/
____
/_/\_\
/\_\/_/\
\/_/\_\/
\_\/_/
________
/ /\ \
/___/ \___\
/\ \ / /\
/ \___\/___/ \
\ / /\ \ /
\/___/ \___\/
\ \ / /
\___\/___/
____________
/ /\ \
/ / \ \
/_____/ \_____\
/\ \ / /\
/ \ \ / / \
/ \_____\/_____/ \
\ / /\ \ /
\ / / \ \ /
\/_____/ \_____\/
\ \ / /
\ \ / /
\_____\/_____/
________________
/ /\ \
/ / \ \
/ / \ \
/_______/ \_______\
/\ \ / /\
/ \ \ / / \
/ \ \ / / \
/ \_______\/_______/ \
\ / /\ \ /
\ / / \ \ /
\ / / \ \ /
\/_______/ \_______\/
\ \ / /
\ \ / /
\ \ / /
\_______\/_______/
____________________
/ /\ \
/ / \ \
/ / \ \
/ / \ \
/_________/ \_________\
/\ \ / /\
/ \ \ / / \
/ \ \ / / \
/ \ \ / / \
/ \_________\/_________/ \
\ / /\ \ /
\ / / \ \ /
\ / / \ \ /
\ / / \ \ /
\/_________/ \_________\/
\ \ / /
\ \ / /
\ \ / /
\ \ / /
\_________\/_________/
________________________
/ /\ \
/ / \ \
/ / \ \
/ / \ \
/ / \ \
/___________/ \___________\
/\ \ / /\
/ \ \ / / \
/ \ \ / / \
/ \ \ / / \
/ \ \ / / \
/ \___________\/___________/ \
\ / /\ \ /
\ / / \ \ /
\ / / \ \ /
\ / / \ \ /
\ / / \ \ /
\/___________/ \___________\/
\ \ / /
\ \ / /
\ \ / /
\ \ / /
\ \ / /
\___________\/___________/
______
/_/_/\_\
/_/\_\/\_\
/\_\/_/\/_/\
\/_/\_\/_/\/
\_\/_/\_\/
\_\_\/_/
____________
/ / /\ \
/___/___/ \___\
/ /\ \ /\ \
/___/ \___\/ \___\
/\ \ / /\ / /\
/ \___\/___/ \/___/ \
\ / /\ \ / /\ /
\/___/ \___\/___/ \/
\ \ / /\ \ /
\___\/___/ \___\/
\ \ \ / /
\___\___\/___/
__________________
/ / /\ \
/ / / \ \
/_____/_____/ \_____\
/ /\ \ /\ \
/ / \ \ / \ \
/_____/ \_____\/ \_____\
/\ \ / /\ / /\
/ \ \ / / \ / / \
/ \_____\/_____/ \/_____/ \
\ / /\ \ / /\ /
\ / / \ \ / / \ /
\/_____/ \_____\/_____/ \/
\ \ / /\ \ /
\ \ / / \ \ /
\_____\/_____/ \_____\/
\ \ \ / /
\ \ \ / /
\_____\_____\/_____/
________________________
/ / /\ \
/ / / \ \
/ / / \ \
/_______/_______/ \_______\
/ /\ \ /\ \
/ / \ \ / \ \
/ / \ \ / \ \
/_______/ \_______\/ \_______\
/\ \ / /\ / /\
/ \ \ / / \ / / \
/ \ \ / / \ / / \
/ \_______\/_______/ \/_______/ \
\ / /\ \ / /\ /
\ / / \ \ / / \ /
\ / / \ \ / / \ /
\/_______/ \_______\/_______/ \/
\ \ / /\ \ /
\ \ / / \ \ /
\ \ / / \ \ /
\_______\/_______/ \_______\/
\ \ \ / /
\ \ \ / /
\ \ \ / /
\_______\_______\/_______/
______________________________
/ / /\ \
/ / / \ \
/ / / \ \
/ / / \ \
/_________/_________/ \_________\
/ /\ \ /\ \
/ / \ \ / \ \
/ / \ \ / \ \
/ / \ \ / \ \
/_________/ \_________\/ \_________\
/\ \ / /\ / /\
/ \ \ / / \ / / \
/ \ \ / / \ / / \
/ \ \ / / \ / / \
/ \_________\/_________/ \/_________/ \
\ / /\ \ / /\ /
\ / / \ \ / / \ /
\ / / \ \ / / \ /
\ / / \ \ / / \ /
\/_________/ \_________\/_________/ \/
\ \ / /\ \ /
\ \ / / \ \ /
\ \ / / \ \ /
\ \ / / \ \ /
\_________\/_________/ \_________\/
\ \ \ / /
\ \ \ / /
\ \ \ / /
\ \ \ / /
\_________\_________\/_________/
____________________________________
/ / /\ \
/ / / \ \
/ / / \ \
/ / / \ \
/ / / \ \
/___________/___________/ \___________\
/ /\ \ /\ \
/ / \ \ / \ \
/ / \ \ / \ \
/ / \ \ / \ \
/ / \ \ / \ \
/___________/ \___________\/ \___________\
/\ \ / /\ / /\
/ \ \ / / \ / / \
/ \ \ / / \ / / \
/ \ \ / / \ / / \
/ \ \ / / \ / / \
/ \___________\/___________/ \/___________/ \
\ / /\ \ / /\ /
\ / / \ \ / / \ /
\ / / \ \ / / \ /
\ / / \ \ / / \ /
\ / / \ \ / / \ /
\/___________/ \___________\/___________/ \/
\ \ / /\ \ /
\ \ / / \ \ /
\ \ / / \ \ /
\ \ / / \ \ /
\ \ / / \ \ /
\___________\/___________/ \___________\/
\ \ \ / /
\ \ \ / /
\ \ \ / /
\ \ \ / /
\ \ \ / /
\___________\___________\/___________/
________
/_/\_\_\_\
/\_\/\_\_\_\
/\/_/\/_/_/\_\
/\/\_\/_/_/\/\_\
\/\/_/\_\_\/\/_/
\/\_\/_/\_\/_/
\/\_\_\/_/_/
\/_/_/_/_/
________________
/ /\ \ \ \
/___/ \___\___\___\
/\ \ /\ \ \ \
/ \___\/ \___\___\___\
/\ / /\ / / /\ \
/ \/___/ \/___/___/ \___\
/\ /\ \ / / /\ /\ \
/ \/ \___\/___/___/ \/ \___\
\ /\ / /\ \ \ /\ / /
\/ \/___/ \___\___\/ \/___/
\ /\ \ / /\ \ / /
\/ \___\/___/ \___\/___/
\ /\ \ \ / / /
\/ \___\___\/___/___/
\ / / / / /
\/___/___/___/___/
________________________
/ /\ \ \ \
/ / \ \ \ \
/_____/ \_____\_____\_____\
/\ \ /\ \ \ \
/ \ \ / \ \ \ \
/ \_____\/ \_____\_____\_____\
/\ / /\ / / /\ \
/ \ / / \ / / / \ \
/ \/_____/ \/_____/_____/ \_____\
/\ /\ \ / / /\ /\ \
/ \ / \ \ / / / \ / \ \
/ \/ \_____\/_____/_____/ \/ \_____\
\ /\ / /\ \ \ /\ / /
\ / \ / / \ \ \ / \ / /
\/ \/_____/ \_____\_____\/ \/_____/
\ /\ \ / /\ \ / /
\ / \ \ / / \ \ / /
\/ \_____\/_____/ \_____\/_____/
\ /\ \ \ / / /
\ / \ \ \ / / /
\/ \_____\_____\/_____/_____/
\ / / / / /
\ / / / / /
\/_____/_____/_____/_____/
________________________________
/ /\ \ \ \
/ / \ \ \ \
/ / \ \ \ \
/_______/ \_______\_______\_______\
/\ \ /\ \ \ \
/ \ \ / \ \ \ \
/ \ \ / \ \ \ \
/ \_______\/ \_______\_______\_______\
/\ / /\ / / /\ \
/ \ / / \ / / / \ \
/ \ / / \ / / / \ \
/ \/_______/ \/_______/_______/ \_______\
/\ /\ \ / / /\ /\ \
/ \ / \ \ / / / \ / \ \
/ \ / \ \ / / / \ / \ \
/ \/ \_______\/_______/_______/ \/ \_______\
\ /\ / /\ \ \ /\ / /
\ / \ / / \ \ \ / \ / /
\ / \ / / \ \ \ / \ / /
\/ \/_______/ \_______\_______\/ \/_______/
\ /\ \ / /\ \ / /
\ / \ \ / / \ \ / /
\ / \ \ / / \ \ / /
\/ \_______\/_______/ \_______\/_______/
\ /\ \ \ / / /
\ / \ \ \ / / /
\ / \ \ \ / / /
\/ \_______\_______\/_______/_______/
\ / / / / /
\ / / / / /
\ / / / / /
\/_______/_______/_______/_______/
________________________________________
/ /\ \ \ \
/ / \ \ \ \
/ / \ \ \ \
/ / \ \ \ \
/_________/ \_________\_________\_________\
/\ \ /\ \ \ \
/ \ \ / \ \ \ \
/ \ \ / \ \ \ \
/ \ \ / \ \ \ \
/ \_________\/ \_________\_________\_________\
/\ / /\ / / /\ \
/ \ / / \ / / / \ \
/ \ / / \ / / / \ \
/ \ / / \ / / / \ \
/ \/_________/ \/_________/_________/ \_________\
/\ /\ \ / / /\ /\ \
/ \ / \ \ / / / \ / \ \
/ \ / \ \ / / / \ / \ \
/ \ / \ \ / / / \ / \ \
/ \/ \_________\/_________/_________/ \/ \_________\
\ /\ / /\ \ \ /\ / /
\ / \ / / \ \ \ / \ / /
\ / \ / / \ \ \ / \ / /
\ / \ / / \ \ \ / \ / /
\/ \/_________/ \_________\_________\/ \/_________/
\ /\ \ / /\ \ / /
\ / \ \ / / \ \ / /
\ / \ \ / / \ \ / /
\ / \ \ / / \ \ / /
\/ \_________\/_________/ \_________\/_________/
\ /\ \ \ / / /
\ / \ \ \ / / /
\ / \ \ \ / / /
\ / \ \ \ / / /
\/ \_________\_________\/_________/_________/
\ / / / / /
\ / / / / /
\ / / / / /
\ / / / / /
\/_________/_________/_________/_________/
________________________________________________
/ /\ \ \ \
/ / \ \ \ \
/ / \ \ \ \
/ / \ \ \ \
/ / \ \ \ \
/___________/ \___________\___________\___________\
/\ \ /\ \ \ \
/ \ \ / \ \ \ \
/ \ \ / \ \ \ \
/ \ \ / \ \ \ \
/ \ \ / \ \ \ \
/ \___________\/ \___________\___________\___________\
/\ / /\ / / /\ \
/ \ / / \ / / / \ \
/ \ / / \ / / / \ \
/ \ / / \ / / / \ \
/ \ / / \ / / / \ \
/ \/___________/ \/___________/___________/ \___________\
/\ /\ \ / / /\ /\ \
/ \ / \ \ / / / \ / \ \
/ \ / \ \ / / / \ / \ \
/ \ / \ \ / / / \ / \ \
/ \ / \ \ / / / \ / \ \
/ \/ \___________\/___________/___________/ \/ \___________\
\ /\ / /\ \ \ /\ / /
\ / \ / / \ \ \ / \ / /
\ / \ / / \ \ \ / \ / /
\ / \ / / \ \ \ / \ / /
\ / \ / / \ \ \ / \ / /
\/ \/___________/ \___________\___________\/ \/___________/
\ /\ \ / /\ \ / /
\ / \ \ / / \ \ / /
\ / \ \ / / \ \ / /
\ / \ \ / / \ \ / /
\ / \ \ / / \ \ / /
\/ \___________\/___________/ \___________\/___________/
\ /\ \ \ / / /
\ / \ \ \ / / /
\ / \ \ \ / / /
\ / \ \ \ / / /
\ / \ \ \ / / /
\/ \___________\___________\/___________/___________/
\ / / / / /
\ / / / / /
\ / / / / /
\ / / / / /
\ / / / / /
\/___________/___________/___________/___________/
20I see you are interested in diamonds now that you've got one next to your user name. – user12205 – 2015-05-21T13:34:37.053
3@ace: You know what they say: diamonds are a moderator's best friend. – Alex A. – 2015-05-21T20:20:07.613
I think I know the answer, but I hope I'm wrong: Leading empty lines would count as leading space, which you declared as illegal? My initial solution has
N-1leading empty lines. :( – Reto Koradi – 2015-05-23T23:40:05.850@RetoKoradi Indeed, no leading newlines. Sorry. – Martin Ender – 2015-05-24T00:00:07.140
1I figured. Cost me about 10 bytes. Not as bad as it looked when I first recognized the problem. – Reto Koradi – 2015-05-24T00:46:02.687
Is a function where one of the parameters is
sys.stdinallowed? – isaacg – 2015-05-31T07:41:26.427@isaacg only if it's a default parameter that doesn't need to be supplied by the caller of the function. – Martin Ender – 2015-05-31T08:33:39.547
I was asking on behalf of http://codegolf.stackexchange.com/a/50685/20080, by the way.
– isaacg – 2015-05-31T08:42:50.913Are you allowed to read the input from a file? – Loovjo – 2015-05-31T09:48:45.580
@Loovjo Nope, sorry, only the usual input methods. – Martin Ender – 2015-05-31T11:31:27.620
@MartinBüttner why? – Loovjo – 2015-05-31T12:14:14.587
@Loovjo Because it's not one of the accepted default input methods, and I don't think it matters as long as everyone is playing by the same rules. – Martin Ender – 2015-05-31T12:24:17.380
@MartinBüttner k. – Loovjo – 2015-05-31T12:25:24.550