public Result <RubikFaceType, int> GetSubcubeFaceAndIndex(RubikSubcube subcube) { var instanceId = subcube.GetInstanceID(); for (var i = 0; i < 9; i++) { if (Front[i].GetInstanceID() == instanceId) { return(Result <RubikFaceType, int> .Create(RubikFaceType.Front, i)); } } for (var i = 0; i < 9; i++) { if (Left[i].GetInstanceID() == instanceId) { return(Result <RubikFaceType, int> .Create(RubikFaceType.Left, i)); } } for (var i = 0; i < 9; i++) { if (Right[i].GetInstanceID() == instanceId) { return(Result <RubikFaceType, int> .Create(RubikFaceType.Right, i)); } } for (var i = 0; i < 9; i++) { if (Top[i].GetInstanceID() == instanceId) { return(Result <RubikFaceType, int> .Create(RubikFaceType.Top, i)); } } for (var i = 0; i < 9; i++) { if (Back[i].GetInstanceID() == instanceId) { return(Result <RubikFaceType, int> .Create(RubikFaceType.Back, i)); } } for (var i = 0; i < 9; i++) { if (Bottom[i].GetInstanceID() == instanceId) { return(Result <RubikFaceType, int> .Create(RubikFaceType.Bottom, i)); } } throw new ArgumentException("This subcube is not contained in the initial state.", "subcube"); }
public List <RubikFaceType> GetSubcubeFaces(RubikSubcube subcube) { var faces = new List <RubikFaceType>(); for (var i = 0; i < 9; i++) { if (subcube.GetInstanceID() == Front[i].GetInstanceID()) { faces.Add(RubikFaceType.Front); break; } } for (var i = 0; i < 9; i++) { if (subcube.GetInstanceID() == Left[i].GetInstanceID()) { faces.Add(RubikFaceType.Left); break; } } for (var i = 0; i < 9; i++) { if (subcube.GetInstanceID() == Right[i].GetInstanceID()) { faces.Add(RubikFaceType.Right); break; } } for (var i = 0; i < 9; i++) { if (subcube.GetInstanceID() == Top[i].GetInstanceID()) { faces.Add(RubikFaceType.Top); break; } } for (var i = 0; i < 9; i++) { if (subcube.GetInstanceID() == Back[i].GetInstanceID()) { faces.Add(RubikFaceType.Back); break; } } for (var i = 0; i < 9; i++) { if (subcube.GetInstanceID() == Bottom[i].GetInstanceID()) { faces.Add(RubikFaceType.Bottom); break; } } return(faces); }