#JavaScript (ES6), (削除) 114 (削除ここまで)(削除) 106 (削除ここまで)(削除) 105 (削除ここまで)(削除) 104 (削除ここまで) 103 bytes
JavaScript (ES6), (削除) 114 (削除ここまで)(削除) 106 (削除ここまで)(削除) 105 (削除ここまで)(削除) 104 (削除ここまで) 103 bytes
n=>(g=x=>v=x*2>w?w-x:x,F=x=>~y?`#
`[~x?(h=g(x--))*g(y)>0&h+v!=n|n>h+v:(y--,x=w,2)]+F(x):'')(y=w=--n*3)
###How?
How?
This builds the output character by character.
Given the input \$n\$, we compute:
$$n'=n-1\\w=3n'$$
For each character at \$(x,y)\$, we compute \$(h,v)\$:
$$h=w/2-\left|x-w/2\right|\\v=w/2-\left|y-w/2\right|$$
The cells belonging to the octagon satisfy one of the following conditions:
- (\$h=0\$ OR \$v=0\$) AND \$h+v\ge n'\$ (in red below)
- \$h+v=n'\$ (in orange below)
For example, with \$n=4\$ (and \$n'=3\$):
$$\begin{matrix}(0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\end{matrix} $$
#JavaScript (ES6), (削除) 114 (削除ここまで)(削除) 106 (削除ここまで)(削除) 105 (削除ここまで)(削除) 104 (削除ここまで) 103 bytes
n=>(g=x=>v=x*2>w?w-x:x,F=x=>~y?`#
`[~x?(h=g(x--))*g(y)>0&h+v!=n|n>h+v:(y--,x=w,2)]+F(x):'')(y=w=--n*3)
###How?
This builds the output character by character.
Given the input \$n\$, we compute:
$$n'=n-1\\w=3n'$$
For each character at \$(x,y)\$, we compute \$(h,v)\$:
$$h=w/2-\left|x-w/2\right|\\v=w/2-\left|y-w/2\right|$$
The cells belonging to the octagon satisfy one of the following conditions:
- (\$h=0\$ OR \$v=0\$) AND \$h+v\ge n'\$ (in red below)
- \$h+v=n'\$ (in orange below)
For example, with \$n=4\$ (and \$n'=3\$):
$$\begin{matrix}(0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\end{matrix} $$
JavaScript (ES6), (削除) 114 (削除ここまで)(削除) 106 (削除ここまで)(削除) 105 (削除ここまで)(削除) 104 (削除ここまで) 103 bytes
n=>(g=x=>v=x*2>w?w-x:x,F=x=>~y?`#
`[~x?(h=g(x--))*g(y)>0&h+v!=n|n>h+v:(y--,x=w,2)]+F(x):'')(y=w=--n*3)
How?
This builds the output character by character.
Given the input \$n\$, we compute:
$$n'=n-1\\w=3n'$$
For each character at \$(x,y)\$, we compute \$(h,v)\$:
$$h=w/2-\left|x-w/2\right|\\v=w/2-\left|y-w/2\right|$$
The cells belonging to the octagon satisfy one of the following conditions:
- (\$h=0\$ OR \$v=0\$) AND \$h+v\ge n'\$ (in red below)
- \$h+v=n'\$ (in orange below)
For example, with \$n=4\$ (and \$n'=3\$):
$$\begin{matrix}(0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\end{matrix} $$
#JavaScript (ES6), (削除) 114 (削除ここまで) (削除) 106 (削除ここまで) (削除) 105 (削除ここまで) 104(削除) 104 (削除ここまで) 103 bytes
n=>(g=x=>v=x*2>w?w-x:x,F=x=>~y?`#
`[~x?+((h=g(x--))*g(y)?h+v>0&h+v!=n:n>h+v)=n|n>h+v:(y--,x=w,2)]+F(x):'')(y=w=--n*3)
###How?
This builds the output character by character.
Given the input \$n\$, we compute:
$$n'=n-1\\w=3n'$$
For each character at \$(x,y)\$, we compute \$(h,v)\$:
$$h=w/2-\left|x-w/2\right|\\v=w/2-\left|y-w/2\right|$$
The cells belonging to the octagon satisfy one of the following conditions:
- (\$h=0\$ OR \$v=0\$) AND \$h+v\ge n'\$ (in red below)
- \$h+v=n'\$ (in orange below)
For example, with \$n=4\$ (and \$n'=3\$):
$$\begin{matrix}(0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\end{matrix} $$
#JavaScript (ES6), (削除) 114 (削除ここまで) (削除) 106 (削除ここまで) (削除) 105 (削除ここまで) 104 bytes
n=>(g=x=>v=x*2>w?w-x:x,F=x=>~y?`#
`[~x?+((h=g(x--))*g(y)?h+v!=n:n>h+v):(y--,x=w,2)]+F(x):'')(y=w=--n*3)
###How?
This builds the output character by character.
Given the input \$n\$, we compute:
$$n'=n-1\\w=3n'$$
For each character at \$(x,y)\$, we compute \$(h,v)\$:
$$h=w/2-\left|x-w/2\right|\\v=w/2-\left|y-w/2\right|$$
The cells belonging to the octagon satisfy one of the following conditions:
- (\$h=0\$ OR \$v=0\$) AND \$h+v\ge n'\$ (in red below)
- \$h+v=n'\$ (in orange below)
For example, with \$n=4\$ (and \$n'=3\$):
$$\begin{matrix}(0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\end{matrix} $$
#JavaScript (ES6), (削除) 114 (削除ここまで) (削除) 106 (削除ここまで) (削除) 105 (削除ここまで) (削除) 104 (削除ここまで) 103 bytes
n=>(g=x=>v=x*2>w?w-x:x,F=x=>~y?`#
`[~x?(h=g(x--))*g(y)>0&h+v!=n|n>h+v:(y--,x=w,2)]+F(x):'')(y=w=--n*3)
###How?
This builds the output character by character.
Given the input \$n\$, we compute:
$$n'=n-1\\w=3n'$$
For each character at \$(x,y)\$, we compute \$(h,v)\$:
$$h=w/2-\left|x-w/2\right|\\v=w/2-\left|y-w/2\right|$$
The cells belonging to the octagon satisfy one of the following conditions:
- (\$h=0\$ OR \$v=0\$) AND \$h+v\ge n'\$ (in red below)
- \$h+v=n'\$ (in orange below)
For example, with \$n=4\$ (and \$n'=3\$):
$$\begin{matrix}(0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\end{matrix} $$
#JavaScript (ES6), (削除) 114 (削除ここまで) (削除) 106 (削除ここまで) 105(削除) 105 (削除ここまで) 104 bytes
n=>(g=x=>v=x*2>w?w-x:x,F=x=>~y?`#
`[~x?+((h=g(x--))*g(y)?h+v-n&&1!=n:n>h&n>vn>h+v):(y--,x=w,2)]+F(x):'')(y=w=--n*3)
###How?
This builds the output character by character.
Given the input \$n\$, we compute:
$$n'=n-1\\w=3n'$$
For each character at \$(x,y)\$, we compute \$(h,v)\$:
$$h=w/2-\left|x-w/2\right|\\v=w/2-\left|y-w/2\right|$$
The cells belonging to the octagon satisfy one of the following conditions:
- (\$h=0\$ OR \$v=0\$) AND \$h+v\ge n'\$ (in red below)
- \$h+v=n'\$ (in orange below)
For example, with \$n=4\$ (and \$n'=3\$):
$$\begin{matrix}(0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\end{matrix} $$
#JavaScript (ES6), (削除) 114 (削除ここまで) (削除) 106 (削除ここまで) 105 bytes
n=>(g=x=>v=x*2>w?w-x:x,F=x=>~y?`#
`[~x?(h=g(x--))*g(y)?h+v-n&&1:n>h&n>v:(y--,x=w,2)]+F(x):'')(y=w=--n*3)
#JavaScript (ES6), (削除) 114 (削除ここまで) (削除) 106 (削除ここまで) (削除) 105 (削除ここまで) 104 bytes
n=>(g=x=>v=x*2>w?w-x:x,F=x=>~y?`#
`[~x?+((h=g(x--))*g(y)?h+v!=n:n>h+v):(y--,x=w,2)]+F(x):'')(y=w=--n*3)
###How?
This builds the output character by character.
Given the input \$n\$, we compute:
$$n'=n-1\\w=3n'$$
For each character at \$(x,y)\$, we compute \$(h,v)\$:
$$h=w/2-\left|x-w/2\right|\\v=w/2-\left|y-w/2\right|$$
The cells belonging to the octagon satisfy one of the following conditions:
- (\$h=0\$ OR \$v=0\$) AND \$h+v\ge n'\$ (in red below)
- \$h+v=n'\$ (in orange below)
For example, with \$n=4\$ (and \$n'=3\$):
$$\begin{matrix}(0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,4)}&(1,4)&(2,4)&(3,4)&(4,4)&(4,4)&(3,4)&(2,4)&(1,4)&\color{red}{(0,4)}\\ \color{red}{(0,3)}&(1,3)&(2,3)&(3,3)&(4,3)&(4,3)&(3,3)&(2,3)&(1,3)&\color{red}{(0,3)}\\ (0,2)&\color{orange}{(1,2)}&(2,2)&(3,2)&(4,2)&(4,2)&(3,2)&(2,2)&\color{orange}{(1,2)}&(0,2)\\ (0,1)&(1,1)&\color{orange}{(2,1)}&(3,1)&(4,1)&(4,1)&(3,1)&\color{orange}{(2,1)}&(1,1)&(0,1)\\ (0,0)&(1,0)&(2,0)&\color{red}{(3,0)}&\color{red}{(4,0)}&\color{red}{(4,0)}&\color{red}{(3,0)}&(2,0)&(1,0)&(0,0)\end{matrix} $$