[Question]
  [
The first *Predecessor-completed Ascii Cube (PAC 1)* is a simple cube with side length 1 and looks like this:
```
 /////\
/////  \
\\\\\  /
 \\\\\/
```
The *PAC 2* is a geometric shape such that combining it with its predecessor (the *PAC 1*) completes a side length 2 cube:
```
      front                back
   /////////\           /////////\
  /////////  \         /////////  \
 /////\\\\\   \       /////////    \
/////  \\\\\   \     /////////      \
\\\\\  /////   /     \\\\\\\\\      /
 \\\\\/////   /       \\\\\\\\\    /
  \\\\\\\\\  /         \\\\\\\\\  /
   \\\\\\\\\/           \\\\\\\\\/
```
Because the *back*-view is kind of boring, we are only interested in the *front*-view.
The same goes for the *PAC 3*: With some visual thinking the *PAC 2* can be turned around and plugged into the *PAC 3* to form a solid side length 3 cube:
```
     /////////////\
    /////////////  \
   /////\\\\\\\\\   \
  /////  \\\\\\\\\   \
 /////   /////\\\\\   \
/////   /////  \\\\\   \
\\\\\   \\\\\  /////   /
 \\\\\   \\\\\/////   /
  \\\\\  /////////   /
   \\\\\/////////   /
    \\\\\\\\\\\\\  /
     \\\\\\\\\\\\\/
```
And so on with *PAC 4*:
```
       /////////////////\
      /////////////////  \
     /////\\\\\\\\\\\\\   \
    /////  \\\\\\\\\\\\\   \
   /////   /////////\\\\\   \
  /////   /////////  \\\\\   \
 /////   /////\\\\\   \\\\\   \
/////   /////  \\\\\   \\\\\   \
\\\\\   \\\\\  /////   /////   /
 \\\\\   \\\\\/////   /////   / 
  \\\\\   \\\\\\\\\  /////   /
   \\\\\   \\\\\\\\\/////   /
    \\\\\  /////////////   /
     \\\\\/////////////   /
      \\\\\\\\\\\\\\\\\  /
       \\\\\\\\\\\\\\\\\/
```
### Task:
Write a full program or function which takes a positive integer n as input and returns or prints the corresponding front-view of *PAC n* exactly as shown above. Additional trailing white space is acceptable.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so try to use as few bytes as possible in the language of your choice.
  
[Answer]
## JavaScript (ES6), 229 bytes
```
f=
(n,l=n*4+1,r=1,i=n*2,g=a=>` / \\ /
`.replace(/./g,c=>c.repeat(a.pop())))=>n?g([r,,l,--i])+g([r,2,l,--i])+f(n-1,l-1?1:r-4,r-1?1:l-4).replace(/(\S).*(.)/g,r-1?`$1   $&$2$2$2$2`:`$1$1$1$1$&   $2`)+g([r,2,l,,,i])+g([r,,l,,,i+1]):``
```
```
<input type=number min=0 oninput=o.textContent=f(+this.value)><pre id=o>
```
[Answer]
## Batch, ~~559~~ ~~432~~ 400 bytes
```
@echo off
set m=
for /l %%i in (1,1,%1)do call set m=  %%m%%
call:c "%m:~2%" %m: =//%/\
exit/b
:c
setlocal
set m=%~1%2%~3
echo  %m%
echo %m:/\=/  \%
set s=%~1
if "%s:~,1%"=="/" goto g
set t=%2
set t=%t:~3,-3%
if %t:~,1%==/ (call:c "%s:~2%////" /\%t:/=\% "   \%~3")else call:c "%s:~2%/   " %t:\=/%/\ "\\\\%~3"
:g
set m=%m:/=-%
set m=%m:\=/%
set m=%m:-=\%
echo %m:\/=\  /%
echo  %m%
```
Explanation: The bottom half of the cube is drawn by reflecting the top half. The halves are further split into ~~seven~~ ~~six~~ three ~~strips~~ parts, as per this diagram showing the top half:
```
1       12/////////////////\233
1      12/////////////////  \233
1     ////12/\\\\\\\\\\\\\23   \3
1    ////12/  \\\\\\\\\\\\\23   \3
1   /////   12/////////\23\\\\   \3
1  /////   12/////////  \23\\\\   \3
1 /////   ////12/\\\\\23   \\\\\   \3
1/////   ////12/  \\\\\23   \\\\\   \3
```
1. The indentation (which decreases every row) and the left triangle, which increases every other row
2. The middle shrinking zigzag triangle, with the small triangle on alternate sides every other row
3. The right triangle, which increases in sync with the left
Edit: Saved over 20% by improving the code that reflected the top to the bottom half. Saved almost 10% by merging the left two and middle three strips.
[Answer]
# [Canvas](https://github.com/dzaima/Canvas), 36 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md)
```
；Ｘø；｛１ｘ／╋
ø╶｛«５⁸２²４×⁸²«１╋²«＼＋；↔５３╋｝═
```
[Try it here!](https://dzaima.github.io/Canvas/?u=JXVGRjFCJXVGRjM4JUY4JXVGRjFCJXVGRjVCJXVGRjExJXVGRjU4JXVGRjBGJXUyNTRCJTBBJUY4JXUyNTc2JXVGRjVCJUFCJXVGRjE1JXUyMDc4JXVGRjEyJUIyJXVGRjE0JUQ3JXUyMDc4JUIyJUFCJXVGRjExJXUyNTRCJUIyJUFCJXVGRjNDJXVGRjBCJXVGRjFCJXUyMTk0JXVGRjE1JXVGRjEzJXUyNTRCJXVGRjVEJXUyNTUw,i=NA__,v=1)
[Answer]
# [SOGL V0.12](https://github.com/dzaima/SOGLOnline), 32 [bytes](https://github.com/dzaima/SOGL/blob/master/chartable.md)
```
ø.∫4*I└*2∙f«5└*∙+¼F«╝┼;↔±53╬5}╬±
```
[Try it here!](https://dzaima.github.io/SOGLOnline/?code=JUY4LiV1MjIyQjQqSSV1MjUxNCoyJXUyMjE5ZiVBQjUldTI1MTQqJXUyMjE5KyVCQ0YlQUIldTI1NUQldTI1M0MlM0IldTIxOTQlQjE1MyV1MjU2QzUlN0QldTI1NkMlQjE_,inputs=NA__,v=0.12)
Simple explanation:  
1. iterate for each of 1..x  
2. make a `⌐` shape with the width of `i*4+1` and height = `(0-indexed)i // 2`  
3. pad it so it looks like `⦧`  
4. append a "\" shape to that horizontally  
5. insert the previous step inside that reversed
6. after everything, mirror vertically
full program:
```
ø                                 push an empty string - starting stage
 .∫                          }    iterate over 1..input
   4*                               multiply the 1-indexed counter by 4
     I                              and add 1
      └*                            repeat "/" that many times
        2∙                          and repeat vertically twice. Top 2 lines are done
          f«                        push the 0-indexed counter floor divided by 2
            5└*                     push "/" repeated 5 times
               ∙                    and repeat that vertically by the result of the "f«"
                +                   add vertically, creating a "⌐" shape
                 ¼                  prepend each next line with one less space than the above
                  F«                push 1-indexed counter floor divided by 2
                    ╝               create a "\" diagonal that long
                     ┼              and append it horizontally. Shell is done of this hexagon
                      ;↔±           get the previous item on the stack and reverse it horizontally
                         53╬5       and at [5;3] insert the previous result in this
                              ╬±  once everything's done, mirror vertically to finish the hexagon
```
[Answer]
# [Haskell](https://www.haskell.org/), ~~232~~ ~~227~~ ~~224~~ ~~187~~ ~~183~~ ~~180~~ 175 bytes
```
m '/'='\\'
m '\\'='/'
m c=c
r=reverse
k=map
n?s=('/'<$[1..4*n])++s
f 0=[]
f n=n?"/\\":n?"/  \\":[1?k m(r s)++"   \\"|s<-f$n-1]
s="":k(' ':)s
((++).r<*>k(k m)).zipWith(++)s.r.f
```
The anonymous function in the last line takes an integer argument and yields the lines to be printed for a cube of that size.
The idea is to use recursion to draw larger cubes from smaller ones. Lets look at the upper half of a cube of size 1. Then we get the upper half of a cube of size 2 by mirroring the former half and add a fixed pattern of slashes and spaces around it:
```
                                         /////////\
                                        /////////  \
     /////\    ==>    /\\\\\    ==>    ////**/\\\\\**   \
    /////  \         /  \\\\\         ////**/ \\\\\**   \
```
So the algorithm to draw a cube of size *n* is
1. Get the lines for the upper cube half of size *n-1*.
2. Mirror each line (by flipping `/`s and `\`s), and pad `////` and  `\` around.
3. Prepend two lines with the pattern `////`*n* plus `/\` and `/ \`.
4. Mirror the resulting lines to get the full cube.
5. Pad lines with appropriate number of spaces.
[Answer]
# [Ruby](https://www.ruby-lang.org/),  ~~174 167 169~~  167 bytes
```
->n{a=(1..m=n*4).map{' '*m}
(-n..0).map{|i|(-2*i).times{|k|a[y=k+2*j=n+i][m+~k+i*2,2+k*2-s=4*i]=?/*(1-~j%2*s)+'  '*k+?\\*(1-j%2*s)
a[~y]=a[y].tr('/\\','\\\\/')}}
a*$/}
```
[Try it online!](https://tio.run/##Jcy7DoMgGEDh3adwaAP8CLTUlfogwECTmiCBGC@DUXx1a@MZv@EM82c5WnWwd1qdwk/Oo0pQEx5dv6ISQcwFZonzx0Wb3zCT4AmffPyO6xY2pxcVqIROJeqtjnQP1IOsJA0g2ahq8FY1AvCT7d1dwkgoKs9zoI0xf72wcHpfrDpvlk8DRsIYVCFzJhDJuXBwE/no52ksW/2yxw8 "Ruby – Try It Online")
creates an array of `n*4` strings filled with spaces, then overwrites it with successively smaller cubes.
**Commented code**
```
->n{a=(1..m=n*4).map{' '*m}                 #make an array of n*4 strings of n*4 spaces (up to centreline of final output)
  (-n..0).map{|i|                           #iterate through cube sizes from n down to 0 (i is negative -n to 0)
    (-2*i).times{|k|                        #iterate through the number of lines in the top half of the cube
      a[y=k+2*j=n+i][m+~k+i*2,2+k*2-s=4*i]= #overwrite the correct part of the correct line
      ?/*(1-~j%2*s)+'  '*k+?\\*(1-j%2*s)    #with the correct string of the form "/spaces\" with an additional -4*i symbols on one side
      a[~y]=a[y].tr('/\\','\\\\/')          #copy the current line from top half into bottom half, subsituting / for \ and vice versa
    }
  }
a*$/}                                       #return the elements of the array a, concatenated with newlines $/
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~254~~ ~~234~~ ~~226~~ ~~203~~ ~~201~~ 199 bytes
Finally sub 200!
```
P=[];n=0
M=lambda r:(u''+r).translate({47:92,92:47})
exec r"n+=1;q='/'*4;P=[q*n+'/\\',q*n+'/  \\']+[q+'%s   \\'%M(r[::-1])for r in P];"*input()
print'\n'.join(l.center(8*n)for l in(P+map(M,P[::-1])))
```
**Tricks:**
This function is used to swap all `\` with `/` and vice versa  
A bit long in Python2 - works only with unicode  
Check out [this](https://codegolf.stackexchange.com/a/48994/66855) for how it works 
```
M=lambda r:(u''+r).translate({47:92,92:47})
```
---
Generates new top two rows for each iteration  
For now I can't find compact way to receive this lines from previous iteration 
```
P=[q*n+'/\\',q*n+'/  \\']
```
---
Reverse all rows of previous iteration and swap slashes 
```
[q+'%s   \\'%M(r[::-1])for r in P]
```
---
Copy top half, reversed by rows, swap slashes 
```
P+map(M,P[::-1])
```
---
Neat method for center padding strings
```
l.center(8*n)
```
[Try it online!](https://tio.run/##LYzBCoJAFADvfsUSxNt1zUqMcmU/QfCuHjbbyNCnvjYoom83qW4zh5nh6S49RtOU66JKUW@8TLemO54MI8XvAJJE6MjgrTXO8le8V0kUJJGK92/h2YetGS1Q6m06aliDH6fzaPRRwrosIfgRYzNXshglLG/sa8uMU6HUaluJc0@MWIMsr9KF3@Bwd1x4AzXooEQIr32DvA1ri84SP/j4Ldq54LnszMCzIP@vhJim3Qc "Python 2 – Try It Online")
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 36 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
äª.$u>↓Z╙╝B↨EXª¡╜?Xáhç∙╩p/♂ù⌠r↨c⌐f/*
```
[Run and debug it](https://staxlang.xyz/#p=84a62e24753e195ad3bc42174558a6adbd3f58a06887f9ca702f0b97f4721763a9662f2a&i=5&a=1)
This approach builds up the top half of the output iteratively. It executes the main block the specified number of times. In that block, each row is mirrored and has a prefix and suffix added. The top two new rows are added separately. When all the rows are built, they're centered, and then the bottom is mirrored vertically.
Here's the program unpacked, ungolfed, and commented.
```
{               begin block to repeat
  iHYH^H'\*     make a string of '\' characters and set the Y register
                  pseudo-code: push(((y = (i * 2)) * 2 + 1) * 2 * '\')
                  given the 0-based iteration index `i`, let y = 2 * i
                  and push a string consisting of (i*8 + 2) backslashes
  2M            split the string into to equal size (i*4 + 1) substrings
  ~+            push array to input stack and concatenate
                  on the first iteration, this is a no-op
                  subsequently, it prepends the array to the result so far
  {             begin a block to use for mapping
    4'\*+       append 4 backslashes to this element
    :R          "brace-wise" reverse
                  this reverses the string AND the slashes in it
    |YH3+92&    write 92 to index (++y * 2 + 3) in the array
                  this puts the trailing backslash at the correct position
                  this will be an out of bounds index, so the string will grow
                  92 is the character code for backslash 
  m             execute map using block
}*              repeat block specified number of times
|C              vertically center all rows
{               begin block for output mapping
  Q             output this line without popping
  :Rr           "brace-wise" reverse, and then actually reverse
                  net effect is to swap forward and backward slashes
m               execute map using block
rm              reverse array, and output all rows
```
[Run this one](https://staxlang.xyz/#c=%7B+++++++++++%09begin+block+to+repeat%0A++iHYH%5EH%27%5C*+%09make+a+string+of+%27%5C%27+characters+and+set+the+Y+register%0A++++++++++++%09++pseudo-code%3A+push%28%28%28y+%3D+%28i+*+2%29%29+*+2+%2B+1%29+*+2+*+%27%5C%27%29%0A++++++++++++%09++given+the+0-based+iteration+index+%60i%60,+let+y+%3D+2+*+i%0A++++++++++++%09++and+push+a+string+consisting+of+%28i*8+%2B+2%29+backslashes%0A++2M++++++++%09split+the+string+into+to+equal+size+%28i*4+%2B+1%29+substrings%0A++%7E%2B++++++++%09push+array+to+input+stack+and+concatenate%0A++++++++++++%09++on+the+first+iteration,+this+is+a+no-op%0A++++++++++++%09++subsequently,+it+prepends+the+array+to+the+result+so+far%0A++%7B+++++++++%09begin+a+block+to+use+for+mapping%0A++++4%27%5C*%2B+++%09append+4+backslashes+to+this+element%0A++++%3AR++++++%09%22brace-wise%22+reverse%0A++++++++++++%09++this+reverses+the+string+AND+the+slashes+in+it%0A++++%7CYH3%2B92%26%09write+92+to+index+%28%2B%2By+*+2+%2B+3%29+in+the+array%0A++++++++++++%09++this+puts+the+trailing+backslash+at+the+correct+position%0A++++++++++++%09++this+will+be+an+out+of+bounds+index,+so+the+string+will+grow%0A++++++++++++%09++92+is+the+character+code+for+backslash+%0A++m+++++++++%09execute+map+using+block%0A%7D*++++++++++%09repeat+block+specified+number+of+times%0A%7CC++++++++++%09vertically+center+all+rows%0A%7B+++++++++++%09begin+block+for+output+mapping%0A++Q+++++++++%09output+this+line+without+popping%0A++%3ARr+++++++%09%22brace-wise%22+reverse,+and+then+actually+reverse%0A++++++++++++%09++net+effect+is+to+swap+forward+and+backward+slashes%0Am+++++++++++%09execute+map+using+block%0Arm++++++++++%09reverse+array,+and+output+all+rows&i=5&a=1)
[Answer]
# Haskell, 193 bytes
Longer than the winner, but the approach may be interesting -- uses even `cos` and `pi` :)
Code:
```
i s e f|max e f>s=""|max e f<s=" "|e==s="\\"|1<2="/"
w n y x=head$do{d<-[1..n];o<-[-2*d..2*d];z<-[(cos(pi*(n-d)))*o+x];i(2*d)(abs$z-y)(abs$z+y-1)}++" "
n!h=h<$>[1-2*n..2*n]
f n=((2*n)!)<$>n!w n
```
Run it like this:
```
mapM_ putStrLn (f 4)
```
This program basically 'draws' many diamonds like this one:
```
------------------------
------------------------
-----------/\-----------
----------/  \----------
---------/    \---------
--------/      \--------
--------\      /--------
---------\    /---------
----------\  /----------
-----------\/-----------
------------------------
------------------------
```
Function `i s e f` 'draws' one diamond of size `s`, where `e, f` are `(abs$z-y)(abs$z+y-1)`.
Function `w` moves the diamonds drawn by `i`
to correct places. `head` used in its definition is responsible for looking at the topmost layer only.
[Try it here](https://tio.run/##RY7NToUwEIXX8hRDw6KFFlP82UB5Al25hC6q5QbiZUrkGuGKz45zjcbNzHfmZM5M7@bX7njc9wFm6OCwjW659Ho2jP2JigSwrTOGoG3ZpqvCsGsWfQDCCovpO@cTHz59pRqd52jLQKSK1Oc5FVueSfKXMPNpSDkqL4RIQ7bYcuDkC@6e5@Ss1l/IVqXFV5bR0Qjj3vRVUjea4vAShzY6ABpOmyhiQR7G9Mg@ugGND9HV6KZH4C2CquGHp/fT0@ntAYHTooC6/p8wJqDRspA38lbeyXu7fwM)
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 42 bytes
```
ＦＮ«↗×⊗⊕ι/↓↘Ｇ↖²→⊕×⁴⊕ι↘²\Ｇ←⁴↘⊕⊗ι→⁴\Ｍ⁴→‖Ｔ»‖Ｍ↓
```
[Try it online!](https://tio.run/##VZCxDoIwEIZneYqmU5tgTAwuuLqYqCEENxashzYpLTkKxhifvRaQKFv73/X77iruBQpTKOdKg4Ttdd3aU1tdABnn5BUsEpTasvhcp/J2tyHJZAUN25n2ouDq@wVCBdr6s@Q8JHRFOd8Gi6PpgMU789Dz20Dpo8So583onnyA0oPXIYm/jn/q6IvmoVd51w84vKZ5TmfkkRvNG/8x0xbD5JM8@pGGsaOp1CcplAqEzbDQjf@wivnwHXzTo0Q0OG3t3MYtO/UB "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
ＦＮ«
```
Draw the cubes from the smallest to the largest. (Drawing from the largest to the smallest meant that I ended up with a mirror image for odd numbers which cost too many bytes to fix.)
```
↗×⊗⊕ι/
```
Print a line of `/`s. (This will become the `\`s on the right, but the drawing is done mirrored because it's golfier to mirror at the end of the loop.)
```
↓↘Ｇ↖²→⊕×⁴⊕ι↘²\
```
Print the top two rows of `\`s. (Drawing all the `\`s in one polygon meant that the cursor ended up in an awkward position which cost too many bytes to fix.)
```
Ｇ←⁴↘⊕⊗ι→⁴\
```
Print the left four rows of `\`s. (The fifth row comes from the previous cube.)
```
Ｍ⁴→
```
Move to the start of the next cube.
```
‖Ｔ»
```
Reflect horizontally ready for the next cube.
```
‖Ｍ↓
```
Mirror everything vertically to complete the cube.
]