How would you represent a Rubik's Cube in code?

前端 未结 11 1781
清酒与你
清酒与你 2020-12-07 09:52

If you were developing software to solve a Rubik\'s Cube, how would you represent the cube?

11条回答
  •  星月不相逢
    2020-12-07 10:08

    As a permutation of the 48 faces which can move. The basic rotations are also permutations, and permutations can be composed, they form a group.

    In a program such a permutation would be represented by an array of 48 elements containing numbers 0 to 47. The colors corresponding to the numbers are fixed, so a visual representation can be computed from the permutation, and vice versa.

提交回复
热议问题