Skip to content

Commit 64b1bff

Browse files
author
Shawn Toubeau
committed
fixed multi-line error
1 parent 26a6f80 commit 64b1bff

File tree

5 files changed

+25
-27
lines changed

5 files changed

+25
-27
lines changed

src/components/Maze/algorithms/A*.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,16 @@ const runAstar = (props: Props) => {
118118
}, 100 / currentSpeed);
119119
};
120120

121-
const aStarDesc =
122-
" ### A* Info\
123-
\nA* pronounced A-Star was originally created in an attempt to create a general purpose robot as part of the Shakey\
124-
project in the 1960’s and 70’s. A* is a best-first search algorithm.\
121+
const aStarDesc = `### A* Info\
122+
\nA\\* pronounced A-Star was originally created in an attempt to create a general purpose robot as part of the Shakey\
123+
project in the 1960’s and 70’s. A\\* is a best-first search algorithm.\
125124
\n### Runtime: \
126125
\nThe time complexity is polynomial when the search space is a tree, there is a single goal state,\
127126
and the heuristic function h meets the following condition:\
128127
\n| h ( x ) − h ∗ ( x ) | = O ( log ⁡ h ∗ ( x ) ) \
129-
\nwhere h* is the optimal heuristic, the exact cost to get from x to the goal.\
128+
\nwhere h\\* is the optimal heuristic, the exact cost to get from x to the goal.\
130129
\n### Helpful links:\
131130
\n[The Coding Train (video part1)] (https://www.youtube.com/watch?v=aKYlikFAV4k&t=968s) \
132-
\n[Computerphile (video)] (https://www.youtube.com/watch?v=ySN5Wnu88nE )";
131+
\n[Computerphile (video)] (https://www.youtube.com/watch?v=ySN5Wnu88nE )`;
133132

134133
export { runAstar, aStarDesc };

src/components/Maze/algorithms/BFS.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,13 @@ const runBFS = (props: Props) => {
7070
return;
7171
};
7272

73-
const bfsDesc =
74-
"### BFS Info\
73+
const bfsDesc = `### BFS Info\
7574
\nBreadth-First Search is a graph or tree traversing algorithm that looks at all nodes at the current level \
7675
before moving onto the next deepest set of nodes. It was created by Konrad Zuse in 1945 and later reinvented by Edward F. Moore in 1959. \
7776
\n### Runtime:\
7877
\nO( | V | + | E |) where V is the number of nodes and E the number of edges.\
7978
\n### Helpful links: \
8079
\n[TheHippieCat (video)] (https://www.youtube.com/watch?v=WvR9voi0y2I)\
81-
\n[Nesbox (README)] (https://github.com/nesbox/TIC-80/wiki/Pathfinding%EA%9E%89-BFS-Algorithm)";
80+
\n[Nesbox (README)] (https://github.com/nesbox/TIC-80/wiki/Pathfinding%EA%9E%89-BFS-Algorithm)`;
8281

8382
export { runBFS, bfsDesc };

src/components/Maze/algorithms/DFS.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,13 @@ const runDFS = (props: Props) => {
6767
}, 100 / currentSpeed);
6868
};
6969

70-
const dfsDesc =
71-
"### DFS Info\
70+
const dfsDesc = `### DFS Info\
7271
\nDepth-first search is a pathfinding or tree spanning algorithm that follows one branch to its deepest point before backtracking. \
7372
It was created in the 19th century by French mathematician Charles Pierre Trémaux. \
7473
\n### Runtime:\
7574
\nO( | V | + | E |) where V is the number of nodes and E the number of edges.\
7675
\n### Helpful links:\
7776
\n[Brilliant (articel)] (https://brilliant.org/wiki/depth-first-search-dfs)\
78-
\n[Go GATE IIT (video)](https://www.youtube.com/watch?v=iaBEKo5sM7w)";
77+
\n[Go GATE IIT (video)](https://www.youtube.com/watch?v=iaBEKo5sM7w)`;
7978

8079
export { runDFS, dfsDesc };

src/components/Maze/algorithms/Djikstras.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,14 @@ const runDjikstras = (props: Props) => {
9696
}, 100 / currentSpeed);
9797
};
9898

99-
const djikstrasDesc =
100-
"### Djikstra's Algorithm Info\
99+
const djikstrasDesc = `### Djikstra's Algorithm Info\
101100
\nDjikstra's shortest path first Algorithm is a pathfinding algorithm created by Edsger W. Djikstra in 1956. \
102101
It uses a min-priority queue to find the shortest path of a weighted graph. \
103102
\n### Runtime: \
104103
\n(Min-priority queue) O(| V | +| E |log| V |) (where | V | s the number of nodes and | E | is the number of edges)\
105104
\n(Array) O(V^2)\
106105
\n### Helpful links:\
107106
\n[Computerphile (video)](https://www.youtube.com/watch?v=GazC3A4OQTE)\
108-
\n[Clément Mihailescu (video)] (https://www.youtube.com/watch?v=msttfIHHkak&t=2826s)";
107+
\n[Clément Mihailescu (video)] (https://www.youtube.com/watch?v=msttfIHHkak&t=2826s)`;
109108

110109
export { runDjikstras, djikstrasDesc };

src/components/Menu/index.tsx

+14-12
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,21 @@ class MenuBar extends React.Component<MenuProps, _MenuState> {
225225
};
226226

227227
getInfo = () => {
228-
let al = this.props.selectedAlgo;
229-
if (al === null) {
230-
al = "Select an algorithm";
231-
} else if (al === Algorithms.astar) {
232-
al = aStarDesc;
233-
} else if (al === Algorithms.bfs) {
234-
al = bfsDesc;
235-
} else if (al === Algorithms.dfs) {
236-
al = dfsDesc;
237-
} else if (al === Algorithms.djikstras) {
238-
al = djikstrasDesc;
228+
const { selectedAlgo } = this.props;
229+
let algoDesc = "";
230+
231+
if (selectedAlgo === null) {
232+
algoDesc = "Select an algorithm";
233+
} else if (selectedAlgo === Algorithms.astar) {
234+
algoDesc = aStarDesc;
235+
} else if (selectedAlgo === Algorithms.bfs) {
236+
algoDesc = bfsDesc;
237+
} else if (selectedAlgo === Algorithms.dfs) {
238+
algoDesc = dfsDesc;
239+
} else if (selectedAlgo === Algorithms.djikstras) {
240+
algoDesc = djikstrasDesc;
239241
}
240-
return al as string;
242+
return algoDesc;
241243
};
242244

243245
render() {

0 commit comments

Comments
 (0)