Skip to content

Commit fcdc9d4

Browse files
committed
Patched some minor issues
1 parent 143ab45 commit fcdc9d4

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
notes.md
1+
notes.md
2+
cubestack2.js
3+
list-test.txt

cubestack/cubestack.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ var lex = (code) => {
109109
tokens.push(new Token("error", "invalid move", move, `${move} is not a valid move on a 3x3 rubiks cube`));
110110
}
111111

112-
for (var move of (code ?? "").replace(/\n/g, " ").replace(/\s\s/g, " ").split(" ").filter(move => !!move)) {
112+
for (var move of (code ?? "").replace(/\s{2,}|\n/g, " ").split(" ").filter(move => !!move)) {
113113
if (state == "string") {
114114
if (base36map.includes(move)) {
115115
token.push(move);

web/visualise.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Returns an object containing what the cube would look like after given moves.
33
*/
44

55
var generateCube = (moves) => {
6-
moves = moves.trim();
6+
moves = moves.trim().replace(/\s{2,}|\n/g, " ")
7+
console.log(moves)
78

89
var cube = {
910
front: Array(9).fill("green"),
@@ -135,7 +136,7 @@ var generateCube = (moves) => {
135136
return flat;
136137
}
137138

138-
if (moves.split(" ").filter(move => !(move in moveMap)).length < 1 || moves.length == 0) {
139+
if (moves.split(" ").filter(move => !!move).filter(move => !(move in moveMap)).length < 1 || moves.length == 0) {
139140
var moves = deepFlatten(moves.split(" ").map(move => (moveMap[move] ?? "").split(" ")));
140141
while (moves.filter(item => !"xyzU".includes(item)).length > 0) {
141142
moves = deepFlatten(moves.map(item => moveMap[item].split(" ")));

0 commit comments

Comments
 (0)