# CUT OUT HEXAGONS

Write a full program or a function taking an unsigned integer number N and doing this cut out work:

• Cut out a hollow hexagon 'donut' shape with side B-C equal to 2N times '/'
• Translate the piece above by 3 lines.
• Repeat the job N times (from the piece obtained) decrementing by 2 '/' side B-C , until smallest hexagon (2 times '/').

This is the smallest hexagon which will be cut out last:

    side B-C     C____D
is 2'/' ->   /    \
B/      \
side  C-D      \      /
is 4'_'          \____/
A


Test cases:

N = 0 may output a blank sheet (nothing), but you don't heave to handle it.

N = 1:

  ____
/    \
/      \
\      /
\____/
/      \
\      /
\____/


N = 3:

          ____
_/    \_
_//      \\_
// \      / \\
//   \____/   \\
//   /______\   \\
/ \   \      /   / \
/   \   \____/   /   \
/   / \          / \   \
\   \  \________/  /   /
\   \            /   /
/ \   \          /   / \
\  \   \________/   /  /
\  \              /  /
\  \____________/  /
\                /
\              /
\____________/


N = 8:

                              ____
_/    \_
_//      \\_
_// \      / \\_
_///   \____/   \\\_
_////   /______\   \\\\_
_//// \   \______/   / \\\\_
_/////   \   \____/   /   \\\\\_
//////   /_\          /_\   \\\\\\
///// \   \__\________/__/   / \\\\\
/////   \   \____________/   /   \\\\\
/////   / \   \          /   / \   \\\\\
//// \   \  \   \________/   /  /   / \\\\
////   \   \  \              /  /   /   \\\\
////   / \   \  \____________/  /   / \   \\\\
/// \   \  \   \                /   /  /   / \\\
///   \   \  \   \              /   /  /   /   \\\
///   / \   \  \   \____________/   /  /   / \   \\\
// \   \  \   \  \                  /  /   /  /   / \\
//   \   \  \   \  \________________/  /   /  /   /   \\
//   / \   \  \   \                    /   /  /   / \   \\
/ \   \  \   \  \   \                  /   /  /   /  /   / \
/   \   \  \   \  \   \________________/   /  /   /  /   /   \
/   / \   \  \   \  \                      /  /   /  /   / \   \
\   \  \   \  \   \  \____________________/  /   /  /   /  /   /
\   \  \   \  \   \                        /   /  /   /  /   /
/ \   \  \   \  \   \                      /   /  /   /  /   / \
\  \   \  \   \  \   \____________________/   /  /   /  /   /  /
\  \   \  \   \  \                          /  /   /  /   /  /
\  \   \  \   \  \________________________/  /   /  /   /  /
\  \   \  \   \                            /   /  /   /  /
\  \   \  \   \                          /   /  /   /  /
\  \   \  \   \________________________/   /  /   /  /
\  \   \  \                              /  /   /  /
\  \   \  \____________________________/  /   /  /
\  \   \                                /   /  /
\  \   \                              /   /  /
\  \   \____________________________/   /  /
\  \                                  /  /
\  \________________________________/  /
\                                    /
\                                  /
\________________________________/


Rules:
- Margins are not specified.
- Standard loopholes are forbidden.
- Standard input/output methods.
- Shortest answer in bytes wins.

• For n=3, it looks like you decrement it and then raise it one line, but I don't see that specified in the directions...Also where is the strip across the center coming from in the bottom twin of the smallest two? Oct 3 '19 at 5:06
• Try it online! maybe I am wrong but it looks like this to me.. Oct 3 '19 at 6:50
• Close, yet so far away.. Let's just say I'm using translucent paper.. xD Will continue when I have some more time, after I've figured out a rule to determine which parts are/aren't displayed in the final result to overwrite them with spaces. Oct 3 '19 at 9:33
• @Arnauld the shapes are stacked "donut"-ish hexagons, so the outer part is opaque and inner - transparent (with the exception of the bottom one) Oct 3 '19 at 12:34
• Suggested test case: n=8. Contains multiple lines both inside and below the top 'donut'. Here the output of my WIP attempt again to see the lines when everything is translucent. Oct 3 '19 at 13:11

# Charcoal, 80 bytes

Ｆ⮌…·¹Ｎ«→↘Ｆ²«Ｍ⁺³×⁴ι↑Ｐ×_⊗ι↙Ｆ⊗ι«ＦκＰ× ⁴↙¹»→Ｆι«ＦκＰ× ⁴↘¹»Ｆ⊖ι«ＦκＰ× ⁻×³ιλ↘¹»\Ｐ×_⊗ι»»‖ＢＯ²


Try it online! Link is to verbose version of code. Explanation:

Ｆ⮌…·¹Ｎ«


Loop from the largest to the smallest hexagon.

→↘Ｆ²«Ｍ⁺³×⁴ι↑


Draw each hexagon twice in the desired location.

Ｐ×_⊗ι


Draw half of the top line of the hexagon.

↙Ｆ⊗ι«ＦκＰ× ⁴↙¹»


Draw the top left diagonal, but for each row erase 4 spaces first if this is the second hexagon.

→Ｆι«ＦκＰ× ⁴↘¹»


Draw half of the bottom left diagonal, still erasing 4 spaces first if this is the second hexagon.

Ｆ⊖ι«ＦκＰ× ⁻×³ιλ↘¹»


Draw almost all of the rest of the bottom left diagonal, erasing until the middle of the hexagon if this is the second hexagon.

\Ｐ×_⊗ι


Finish the bottom left diagonal and draw half of the bottom line of the hexagon.

»»‖ＢＯ²


Mirror everything at the end.

Alternative approach, also 80 bytes:

Ｆ⮌…·¹Ｎ«→↘Ｆ²«Ｍ⁺³×⁴ι↑ＦκＧ→⊗ι↓³←⊖⊗ι↙⊖⊗ι↘⊖⊗ι→⊖⊗ι↓³←⊗ι↖⊕⊗ι↗⊕⊗ι Ｐ×_⊗ι↙↙⊗ι→↘⊗ι↑Ｐ×_⊗ι»»‖Ｍ


Try it online! Link is to verbose version of code. Explanation:

Ｆ⮌…·¹Ｎ«


Loop from the largest to the smallest hexagon.

→↘Ｆ²«Ｍ⁺³×⁴ι↑


Draw each hexagon twice in the desired location.

ＦκＧ→⊗ι↓³←⊖⊗ι↙⊖⊗ι↘⊖⊗ι→⊖⊗ι↓³←⊗ι↖⊕⊗ι↗⊕⊗ι


Before drawing the second hexagon, erase the area between it and the next smaller hexagon.

Ｐ×_⊗ι↙↙⊗ι→↘⊗ι↑Ｐ×_⊗ι»»‖Ｍ


Draw the left half of each hexagon, and then mirror everything at the end.

# Canvas, 113 112 bytes

«/＊α_×－／═↔⁸３＋ ＊－╶Ｒ⇵｛；Ｘ：«ｗ╷/###/＊Ｋｋｙ┤_×＋－ｙ#×/×－ｙ_×－／═ŗ∙ #⟳#¶#╋# ⟳_╋↔ｘ“kｙv╴e┌/ｉ┴⁰U＜ａlisｓfr↖；,ｉmＦE！↷qB╪²－‟＃ŗ｝#∙ ╋↔║


Try it here!

A part of the answer is literally evaluating the JavaScript p.p.overlap(p.p,0,p.p,(a,b)=>b==0?a:b)..

• I was wondering where the evaluation would be useful. Pretty cool! Nov 4 '20 at 5:14

# C (clang), 374 bytes

#define F(X,R)*d=*(d=o+x*(l*3+35-g)+x/2+X+R)-32?*d:R?
i,z,x,l,w,r,g,m;f(n){int*d,o[i=z=(x=n*8+1)*(n*5+4)],*c=o;for(;l=i--;)*c++=i%x?32:10;for(;l++<n;)for(g=35;i=g-29;g-=3){for(r=m+=m=w=l*2;r--;F(~-w*x-w,r)g:g)F(w*~x,r)95:95,F(w*x-w,r)95:95;for(;w--;)for(r=4;r--;F(m-~w*~-x,-r)g:47)F(w-m-w*x,r)g:47,F(w-m-~w*x,r)g:92,F(m+~w-w*x,-r)g:92;}for(;i<z;++i)printf(o[i]-35?o+i:" ");}


Try it online!

-33 more saved by @ceilingcat improvement

# C (clang), 433412 407 bytes

#define F(Y,X,W,R)*d=*(d=c-Y+X+W+R)-32?*d:R?
i,z,x,l,w,r,d,G,g,m;f(n){int*c,*d,o[i=z=(x=n*8+1)*(n*5+4)];for(c=o;l=i--;)*c++=i%x?32:10;for(;l++<n;)for(G=0;i=G<4;G+=3){g=35-G;c=o+x*l*3+G*x+x/2;for(r=m+=m=w=l*2;r--;F(x-w*x,-w,0,r)g:g)F(w*x,-w,0,r)95:95,F(-w*x,-w,0,r)95:95;for(;w--;)for(r=4;r--;F(~w*x,m,~w,-r)g:47)F(w*x,-m,w,r)g:47,F(~w*x,-m,w,r)g:92,F(w*x,m,~w,-r)g:92;}for(;i<z;)i+=printf(o[i]-35?o+i:" ");}


Try it online!

-21 thanks to @ceilingcat -5 @ceilingcat + y removed

   ###\
###\   <= we  draw only on spaces ' '
\###
\###        first time we draw '#' for collisions

/####\
/######\
\######/
\####/

____
/####\        then we move our drawing pointer
/######\     3 lines below
\######/
\____/         and we draw spaces
/      \       instead of #
\      /
\____/

____
_/####\
//######\     and we repeat for bigger donuts
/#\######/   moving our drawing pointer
/###\____/
/###/      \
\###\      /
\###\____/
\####??####/
\________/