3 deleted 38 characters in body
source | link

APL (Dyalog), 31 bytes SBCS31 22 bytes

9 bytes saved thanks to @H.PWiz

{1=⍵:0⋄+/0=+/(⍳⍵)×⍤1↑1⊥0=⊂∘⍳+.ר∘,3-2×⍳⍵⍴2}2×∘⍳⍴∘2

Try it online!Try it online!

APL (Dyalog), 31 bytes SBCS

{1=⍵:0⋄+/0=+/(⍳⍵)×⍤1↑,3-2×⍳⍵⍴2}

Try it online!

APL (Dyalog), 31 22 bytes

9 bytes saved thanks to @H.PWiz

1⊥0=⊂∘⍳+.ר∘,3-2×∘⍳⍴∘2

Try it online!

2 deleted 30 characters in body
source | link

APL (Dyalog), 4431 bytes SBCS

{1=⍵:0⋄+/0=+/(⍳⍵)×⍤1↑(,1 ¯1∘.,⊢)⍣(⍵3-1)⊢1 ¯12×⍳⍵⍴2}

Try it online!Try it online!

APL (Dyalog), 44 bytes SBCS

{1=⍵:0⋄+/0=+/(⍳⍵)×⍤1↑(,1 ¯1∘.,⊢)⍣(⍵-1)⊢1 ¯1}

Try it online!

APL (Dyalog), 31 bytes SBCS

{1=⍵:0⋄+/0=+/(⍳⍵)×⍤1↑,3-2×⍳⍵⍴2}

Try it online!

1
source | link

APL (Dyalog), 44 bytes SBCS

{1=⍵:0⋄+/0=+/(⍳⍵)×⍤1↑(,1 ¯1∘.,⊢)⍣(⍵-1)⊢1 ¯1}

Try it online!