Skip to content

Commit

Permalink
Fix bug in slice fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
simonkellly committed May 22, 2024
1 parent a439417 commit 182b636
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/solutionParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function applyRotation(rotation: string, move: string) {
return result;
}

function fixSlicesForComm(alg: Alg, puzzle: KPuzzle) {
export function fixSlicesForComm(alg: Alg, puzzle: KPuzzle) {
const transformation = puzzle.algToTransformation(alg);
const centerPermutations =
transformation.transformationData['CENTERS'].permutation;
Expand Down Expand Up @@ -109,8 +109,8 @@ function fixSlicesForComm(alg: Alg, puzzle: KPuzzle) {
let newMoves: string[] | undefined;
for (let i = moves.length - 1; i >= 0; i--) {
const move = moves[i];
const isFirst = move[0] == neededMove[0];
const isSecond = move[0] == neededMove[1];
const isFirst = move == neededMove[0];
const isSecond = move == neededMove[1];
if (isFirst || isSecond) {
const altMove = isFirst ? neededMove[1] : neededMove[0];
const oppositeMove =
Expand Down
8 changes: 8 additions & 0 deletions tests/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,12 @@ describe('Extract Comms', () => {
expect(extracted.length).toBe(1);
expect(extracted[0][0]).toBe("[U' M: [U', R' E R]]");
});

test('Extract slice alg (RI) with wide move canceling', async () => {
const extracted = await extractAlgs(
"R U R' U' R' L F R F' L'".split(' ')
);
expect(extracted.length).toBe(1);
expect(extracted[0][0]).toBe("[R: [U R' U', M']]");
});
});

0 comments on commit 182b636

Please sign in to comment.