Problem 60979. Mesh the cube

Problem statement : mesh the cube with quadranglar / squared faces
An cube / regular hexahedron is a regular polyhedron with 8 vertices and 6 squared / quadrangular faces. It is also one of the five well known platonic solids.
A quadrangular mesh F (stands for faces here) is simply a N x 4 matrix of positive integers where each row contains the vertex indices of squared faces, and where N is the number of faces.
Your task here is to mesh this cube. To do so, you will list the squares/rows in a matrix of faces, F. You will also be careful to always keep the faces coherently / consistently oriented (all clockwise or all counterclockwise : square [1, 2, 3, 4] and [4, 3, 2, 1] are distinct).
On the other hand [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2] and [4, 1, 2, 3] are one same unique square.
The row order of the faces in the list doesn't matter.
Edit / update
Faces orientation not taken into account anymore, because of too many possible cases to check in the tests (!)
Example
The first square (Z > 0) here can be [1, 2, 3, 4] if counterclockwise oriented (normals outward).
Forbidden functions / expressions
  • regexp
  • assignin
  • str2num
  • echo
See also

Solution Stats

80.0% Correct | 20.0% Incorrect
Last Solution submitted on Sep 09, 2025

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers22

Suggested Problems

More from this Author42

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!