Skip to content

Commit

Permalink
explain the cube rotations
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Jan 2, 2025
1 parent 1f13668 commit c0d950e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions solutions/src/2022/22_alt.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,24 @@ applyCommand maze = \case
Right DR -> locRotateL

-- | Symmetric group S4 corresponds to the symmetries of a cube.
--
-- This cube's diagonals are labeled and the face is read off the
-- top clockwise. Rotations about an axis use left-hand rule.
--
-- @
-- 0--1 z
-- /| /| |
-- 3--2 | o-x
-- | 2|-3 /
-- |/ |/ y
-- 1--0
-- @
type S4 = Permutation 4

rotX, rotY, rotZ :: S4
rotX = mkPermutation ([3,0,1,2]!!)
rotX = mkPermutation ([3,2,0,1]!!)
rotY = mkPermutation ([2,0,3,1]!!)
rotZ = mkPermutation ([2,3,1,0]!!)
rotZ = mkPermutation ([3,0,1,2]!!)

-- | A pair a rotation of a cube face and a position on that face.
data Loc = Loc S4 Coord
Expand Down

0 comments on commit c0d950e

Please sign in to comment.