Use a dictionary:
class NxNCube: def __init__(self, n): self.n = n # Represent 6 faces (U, D, L, R, F, B), each an n x n grid self.faces = 'U': [['W' for _ in range(n)] for _ in range(n)], 'D': [['Y' for _ in range(n)] for _ in range(n)], 'L': [['O' for _ in range(n)] for _ in range(n)], 'R': [['R' for _ in range(n)] for _ in range(n)], 'F': [['G' for _ in range(n)] for _ in range(n)], 'B': [['B' for _ in range(n)] for _ in range(n)] def rotate_face_clockwise(self, face_key): """Rotates a single face's 2D array 90 degrees clockwise.""" self.faces[face_key] = [list(row) for row in zip(*self.faces[face_key][::-1])] def move_r(self, layer=1): """ Rotates the R-th layer from the right. For NxN, 'layer' determines which vertical slice moves. """ # Logic to swap slices between U, F, D, B faces pass Use code with caution. Copied to clipboard Advanced Functionality to Include dwalton76/rubiks-cube-NxNxN-solver - GitHub nxnxn rubik 39-s-cube algorithm github python
def apply_algorithm(self, moves): # Parse notation like "2R", "3U'", etc. pass Use a dictionary: class NxNCube: def __init__(self, n):