Count the corners, edges and faces of a cut cube

Perl 6, 59 58 bytes

{6+@_,|((2,3 X*4+@_)X-(@_ X~@_)∩~<<ords "% 286
>C/")}

Try it online!

Uses the numbers 0 to 7 to represent the corners. I probably should have matched them up to the same order as in the question... oops? Outputs a list in the order faces, corners, edges.


Charcoal, 48 45 bytes

≔Eθ↨℅ι²η≔⊘№⭆η⭆ηΣEι↔⁻§λξν1ηIE⟦⁶⁻⁸η⁻¹²η⟧⁺ι×⊕κLθ

Try it online! Link is to verbose version of code. Uses digits 0-7 to represent the letters ABDCEFHG in the diagram. Outputs in the order faces, corners, edges. Explanation:

≔Eθ↨℅ι²η

Take the ASCII code of each character and convert it to base 2.

≔⊘№⭆η⭆η

Take the cartesian product of the list of base 2 numbers with itself.

ΣEι↔⁻§λξν1η

XOR the pairs of base 2 numbers together and sum the number of 1 bits. Count how many pairs have a sum of 1 and divide that by 2. This gives the number of coincident corners.

IE⟦⁶⁻⁸η⁻¹²η⟧⁺ι×⊕κLθ

Calculate and print the number of faces, corners and edges.


JavaScript (Node.js), 84 bytes

a=>[a.map(u=>a.map(v=>j-=!!'ABCDAEFGHEFBCGHD'.match(u+v),n++,j+=2),n=j=6)|2+j,n+j,n]

Try it online!

Tags:

Code Golf