Skip to content

Commit aac21d0

Browse files
committed
[Algorithm Design and Techniques]
1 parent d64478d commit aac21d0

8 files changed

+82
-3
lines changed

examples/PacktDataStructuresAlgorithms.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/PacktDataStructuresAlgorithms.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const { bubbleSort } = PacktDataStructuresAlgorithms;

examples/chapter14/11-RatInMaze.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const { ratInAMaze } = PacktDataStructuresAlgorithms;
2+
3+
const maze = [
4+
[1, 0, 0, 0],
5+
[1, 1, 1, 1],
6+
[0, 0, 1, 0],
7+
[0, 1, 1, 1]
8+
];
9+
10+
console.log(ratInAMaze(maze));

examples/chapter14/12-SudokuSolver.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const { sudokuSolver } = PacktDataStructuresAlgorithms;
2+
3+
const sudokuGrid = [
4+
[5, 3, 0, 0, 7, 0, 0, 0, 0],
5+
[6, 0, 0, 1, 9, 5, 0, 0, 0],
6+
[0, 9, 8, 0, 0, 0, 0, 6, 0],
7+
[8, 0, 0, 0, 6, 0, 0, 0, 3],
8+
[4, 0, 0, 8, 0, 3, 0, 0, 1],
9+
[7, 0, 0, 0, 2, 0, 0, 0, 6],
10+
[0, 6, 0, 0, 0, 0, 2, 8, 0],
11+
[0, 0, 0, 4, 1, 9, 0, 0, 5],
12+
[0, 0, 0, 0, 8, 0, 0, 7, 9]
13+
];
14+
15+
console.log(sudokuSolver(sudokuGrid));

examples/index.html

+47
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
<a href="#scroll-tab-9" class="mdl-layout__tab">09</a>
5050
<a href="#scroll-tab-10" class="mdl-layout__tab">10</a>
5151
<a href="#scroll-tab-11" class="mdl-layout__tab">11</a>
52+
<a href="#scroll-tab-12" class="mdl-layout__tab">12</a>
53+
<a href="#scroll-tab-13" class="mdl-layout__tab">13</a>
54+
<a href="#scroll-tab-14" class="mdl-layout__tab">14</a>
55+
<a href="#scroll-tab-15" class="mdl-layout__tab">15</a>
5256
</div>
5357
</header>
5458
<main class="mdl-layout__content">
@@ -218,6 +222,49 @@
218222
</div>
219223
</div>
220224
</section>
225+
<section class="mdl-layout__tab-panel" id="scroll-tab-12">
226+
<div class="page-content">
227+
<div class="page-content mdl-layout--fixed-drawer">
228+
<div class="mdl-layout__drawer is-visible">
229+
<nav class="mdl-navigation">
230+
</nav>
231+
</div>
232+
</div>
233+
</div>
234+
</section>
235+
<section class="mdl-layout__tab-panel" id="scroll-tab-13">
236+
<div class="page-content">
237+
<div class="page-content mdl-layout--fixed-drawer">
238+
<div class="mdl-layout__drawer is-visible">
239+
<nav class="mdl-navigation">
240+
</nav>
241+
</div>
242+
</div>
243+
</div>
244+
</section>
245+
<section class="mdl-layout__tab-panel" id="scroll-tab-14">
246+
<div class="page-content">
247+
<div class="page-content mdl-layout--fixed-drawer">
248+
<div class="mdl-layout__drawer is-visible">
249+
<nav class="mdl-navigation">
250+
<a class="mdl-navigation__link" href="chapter14/01-DC-BinarySearch.html">01-DC-BinarySearch</a>
251+
<a class="mdl-navigation__link" href="chapter14/02-MinCoinChangeDP.html">02-MinCoinChangeDP</a>
252+
<a class="mdl-navigation__link" href="chapter14/03-MinCoinChangeGreedy.html">03-MinCoinChangeGreedy</a>
253+
<a class="mdl-navigation__link" href="chapter14/04-KnapsackProblemDP.html">04-KnapsackProblemDP</a>
254+
<a class="mdl-navigation__link" href="chapter14/05-KnapSackProblemRecursive.html">05-KnapSackProblemRecursive</a>
255+
<a class="mdl-navigation__link" href="chapter14/06-KnapSackProblemGreedy.html">06-KnapSackProblemGreedy</a>
256+
<a class="mdl-navigation__link" href="chapter14/07-LongestCommonSubsequenceDP.html">07-LongestCommonSubsequenceDP</a>
257+
<a class="mdl-navigation__link" href="chapter14/08-LongestCommonSubsequenceRecursive.html">08-LongestCommonSubsequenceRecursive</a>
258+
<a class="mdl-navigation__link" href="chapter14/09-MatrixChainMultiplicationDP.html">09-MatrixChainMultiplicationDP</a>
259+
<a class="mdl-navigation__link" href="chapter14/10-MatrixChainMultiplicationRecursive.html">10-MatrixChainMultiplicationRecursive</a>
260+
<a class="mdl-navigation__link" href="chapter14/11-RatInMaze.html">11-RatInMaze</a>
261+
<a class="mdl-navigation__link" href="chapter14/12-SudokuSolver.html">12-SudokuSolver</a>
262+
<a class="mdl-navigation__link" href="chapter14/13-IntroFunctionalProgramming.html">13-IntroFunctionalProgramming</a>
263+
</nav>
264+
</div>
265+
</div>
266+
</div>
267+
</section>
221268
</main>
222269
</div>
223270
</body>

src/js/algorithms/backtracking/rat-in-maze.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function ratInAMaze(maze) {
3434
solution[i][j] = 0;
3535
}
3636
}
37-
if (findPath(maze, 0, 0, solution) === false) {
37+
if (findPath(maze, 0, 0, solution) === true) {
3838
return solution;
3939
}
4040
return 'NO PATH FOUND';

src/js/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,9 @@ export { interpolationSearch } from './algorithms/search/interpolation-search';
8181
export { sequentialSearch } from './algorithms/search/sequential-search';
8282
export { findMaxValue } from './algorithms/search/min-max-search';
8383
export { findMinValue } from './algorithms/search/min-max-search';
84+
85+
// chapter 14
86+
// export { binarySearch as binarySearchRecursive } from './algorithms/search/binary-search-recursive';
87+
export { minCoinChange } from './algorithms/dynamic-programing/min-coin-change';
88+
export { ratInAMaze } from './algorithms/backtracking/rat-in-maze';
89+
export { sudokuSolver } from './algorithms/backtracking/sudoku-solver';

0 commit comments

Comments
 (0)